I am trying to get started with downloading this project: https://github.com/sadighian/crypto-rl
And I’ve downloaded the packages in the requirements file but I can’t figure out why the artic package won’t download. I am getting this error:
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [312 lines of output]
/Users/aishahalane/venv/lib/python3.9/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
warnings.warn(
error: subprocess-exited-with-error
× Building wheel for numpy (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [269 lines of output]
…
error: Command "/opt/concourse/worker/volumes/live/c1a1a6ef-e724-4ad9-52a7-d6d68451dacb/volume/python-split_1631807121927/_build_env/bin/llvm-ar rcs build/temp.macosx-10.9-x86_64-3.9/libnpymath.a build/temp.macosx-10.9-x86_64-3.9/numpy/core/src/npymath/npy_math.o build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/numpy/core/src/npymath/ieee754.o build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/numpy/core/src/npymath/npy_math_complex.o build/temp.macosx-10.9-x86_64-3.9/numpy/core/src/npymath/halffloat.o" failed with exit status 127
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for numpy
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File "/Users/aishahalane/venv/lib/python3.9/site-packages/setuptools/installer.py", line 82, in fetch_build_egg
subprocess.check_call(cmd)
File "/Users/aishahalane/opt/anaconda3/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/aishahalane/venv/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/_p/xqkc7m_n2_ngn8wdd3pgytp80000gn/T/tmph3_m5ewf', '--quiet', 'numpy<=1.18.4']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/_p/xqkc7m_n2_ngn8wdd3pgytp80000gn/T/pip-req-build-s7mgwt47/setup.py", line 59, in <module>
setup(
File "/Users/aishahalane/venv/lib/python3.9/site-packages/setuptools/__init__.py", line 154, in setup
_install_setup_requires(attrs)
File "/Users/aishahalane/venv/lib/python3.9/site-packages/setuptools/__init__.py", line 148, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/Users/aishahalane/venv/lib/python3.9/site-packages/setuptools/dist.py", line 812, in fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/Users/aishahalane/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 771, in resolve
dist = best[req.key] = env.best_match(
File "/Users/aishahalane/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1056, in best_match
return self.obtain(req, installer)
File "/Users/aishahalane/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1068, in obtain
return installer(requirement)
File "/Users/aishahalane/venv/lib/python3.9/site-packages/setuptools/dist.py", line 883, in fetch_build_egg
return fetch_build_egg(self, req)
File "/Users/aishahalane/venv/lib/python3.9/site-packages/setuptools/installer.py", line 84, in fetch_build_egg
raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['/Users/aishahalane/venv/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/_p/xqkc7m_n2_ngn8wdd3pgytp80000gn/T/tmph3_m5ewf', '--quiet', 'numpy<=1.18.4']' returned non-zero exit status 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
How do I solve this problem?
When running the pip install
command to install a package, you might see the following error:
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
This error occurs because the setup.py
file that your package has can’t be executed properly.
You should be able to see this error a few lines after you run the install command. For example, here I’m trying to install the dotenv
package:
$ pip install dotenv
Collecting dotenv
Using cached dotenv-0.0.5.tar.gz (2.4 kB)
Preparing metadata (setup.py) ... error
When pip
says Preparing metadata from setup.py
, the result is an error.
But why does pip
fail to generate metadata? It could be any one of the following causes:
- You have outdated
pip
,setuptools
, andwheel
packages - The package is no longer maintained
- The package doesn’t support the latest Python version yet
- The package has external dependencies that must be met
This article shows examples of how this error occurs and how to fix it.
Running the pip install
command triggers the Python build systems which use the setuptools
and wheels
packages in the process.
This error can appear when you have outdated build tools in your system.
Before you try anything else, please upgrade these build tools to the latest versions.
You can use one of the following commands:
# For Unix/ macOS:
python3 -m pip install --upgrade pip setuptools wheel
# For windows:
py -m pip install --upgrade pip setuptools wheel
Once you upgraded the build tools to the latest versions, try installing the package again and see if it works now.
2. The package is no longer maintained
The other cause for this error is that the package you try to install is no longer maintained, so it causes an error when changes are introduced in setuptools
or wheel
package.
For example, the dotenv
package hasn’t been updated in a while, so trying to install it with the latest Python version will cause an error.
Fortunately, there’s an alternative package for dotenv
called python-dotenv
that’s actively maintained.
If this is the cause for your package, then the only solution is to find an alternative that works.
3. The package doesn’t support the latest Python version yet
Sometimes, the package you try to install doesn’t support the latest version of Python.
This can happen when Python released a new stable version just a few days or weeks before, and you’re already upgrading it to the latest version.
For example, the pygame
package uses C code, so it needs to rebuild a new wheel package for every Python version.
When there’s no wheel package for your Python version, pip
will try to build the package from source. Most likely, it will fail because you don’t have the development environment to build the package successfully.
In the case of pygame, the maintainer has released a new wheels package as a developer build to test it for errors first.
You can install the latest developer build by adding the --pre
option to the installation command as follows:
pip install pygame --pre
# If you have pip3:
pip3 install pygame --pre
Keep in mind that not all packages support the latest Python version even in their developer builds.
You need to ask the maintainers directly if this is the case with the package you want to install.
4. Your package has external dependencies that must be met
Some Python packages need to have their external dependencies met for the installation to run smoothly.
For example, database adapters like psycopg2
require the C compiler and other external dependencies. You need to have pg_config
executable available in your system as well.
You can see the build prerequisites doc for more information.
UPDATE: There’s a new package called psycopg
that uses pure Python code, so you might want to use that instead of psycopg2
.
If you encounter this error, then you need to check on the homepage of your package and see if there are any requirements for installing that package.
Conclusion
As you can see, the Python error: metadata-generation-failed
message has many possible causes.
The examples shown here are just a few causes for the error. You might even have a different cause altogether.
If you’re not sure how to fix the error, then you can try posting the error message on StackOverflow to get help.
If the package has a GitHub page, you can also check the issues page and see if there’s any mention of the same error.
I hope this tutorial is helpful. See you in other articles! 👋
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.3 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Pygame doesn’t distribute prebuilt distributions for beta versions of Python. So for 3.11, you have to build from source. https://www.pygame.org/wiki/CompileWindows
That’s also doesn’t work for me, same error
Stack trace/error output/other error logs:
C:WindowsSystem32>python3.11 -m pip install setuptools
Requirement already satisfied: setuptools in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (63.2.0)
C:WindowsSystem32>git clone https://github.com/pygame/pygame.git
fatal: destination path 'pygame' already exists and is not an empty directory.
C:WindowsSystem32>cd pygame
C:WindowsSystem32pygame>python3.11 -m pip install setuptools requests wheel numpy -U
Requirement already satisfied: setuptools in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (63.2.0)
Requirement already satisfied: requests in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (2.28.1)
Requirement already satisfied: wheel in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (0.37.1)
Requirement already satisfied: numpy in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (1.23.1)
Requirement already satisfied: charset-normalizer<3,>=2 in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (from requests) (2.1.0)
Requirement already satisfied: idna<4,>=2.5 in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (from requests) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (from requests) (1.26.10)
Requirement already satisfied: certifi>=2017.4.17 in c:userstuankappdatalocalpackagespythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0localcachelocal-packagespython311site-packages (from requests) (2022.6.15)
C:WindowsSystem32pygame>python3.11 -m buildconfig --download
Using WINDOWS configuration...
WARNING:root:Using the SDL libraries in "prebuilt-x64".
Path for SDL: prebuilt-x64SDL2-2.0.22
...Library directory for SDL: prebuilt-x64/SDL2-2.0.22/lib/x64
...Include directory for SDL: prebuilt-x64/SDL2-2.0.22/include
Path for FONT: prebuilt-x64SDL2_ttf-2.0.19
...Library directory for FONT: prebuilt-x64/SDL2_ttf-2.0.19/lib/x64
...Include directory for FONT: prebuilt-x64/SDL2_ttf-2.0.19/include
Path for IMAGE: prebuilt-x64SDL2_image-2.0.5
...Library directory for IMAGE: prebuilt-x64/SDL2_image-2.0.5/lib/x64
...Include directory for IMAGE: prebuilt-x64/SDL2_image-2.0.5/include
Path for MIXER: prebuilt-x64SDL2_mixer-2.0.4
...Library directory for MIXER: prebuilt-x64/SDL2_mixer-2.0.4/lib/x64
...Include directory for MIXER: prebuilt-x64/SDL2_mixer-2.0.4/include
Path for PORTMIDI: prebuilt-x64
...Library directory for PORTMIDI: prebuilt-x64/lib
...Include directory for PORTMIDI: prebuilt-x64/include
DLL for SDL2: prebuilt-x64/SDL2-2.0.22/lib/x64/SDL2.dll
DLL for SDL2_ttf: prebuilt-x64/SDL2_ttf-2.0.19/lib/x64/SDL2_ttf.dll
DLL for SDL2_image: prebuilt-x64/SDL2_image-2.0.5/lib/x64/SDL2_image.dll
DLL for SDL2_mixer: prebuilt-x64/SDL2_mixer-2.0.4/lib/x64/SDL2_mixer.dll
DLL for portmidi: prebuilt-x64/lib/portmidi.dll
Path for FREETYPE: prebuilt-x64
...Library directory for FREETYPE: prebuilt-x64/lib
...Include directory for FREETYPE: prebuilt-x64/include
Path for PNG not found.
...Found include dir but no library dir in prebuilt-x64.
Path for JPEG not found.
...Found include dir but no library dir in prebuilt-x64.
DLL for freetype: prebuilt-x64/lib/freetype.dll
DLL for png: prebuilt-x64/SDL2_image-2.0.5/lib/x64/libpng16-16.dll
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:WindowsSystem32pygamebuildconfig__main__.py", line 2, in <module>
main()
File "C:WindowsSystem32pygamebuildconfigconfig.py", line 231, in main
deps = CFG.main(**kwds, auto_config=auto)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:WindowsSystem32pygamebuildconfigconfig_win.py", line 500, in main
return setup_prebuilt_sdl2(prebuilt_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:WindowsSystem32pygamebuildconfigconfig_win.py", line 460, in setup_prebuilt_sdl2
DEPS.configure()
File "C:WindowsSystem32pygamebuildconfigconfig_win.py", line 336, in configure
from . import vstools
File "C:WindowsSystem32pygamebuildconfigvstools.py", line 8, in <module>
compiler.initialize()
File "C:UserstuankAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagessetuptools_distutilsmsvc9compiler.py", line 393, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UserstuankAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagessetuptoolsmsvc.py", line 140, in msvc9_query_vcvarsall
return EnvironmentInfo(arch, ver).return_env()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UserstuankAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagessetuptoolsmsvc.py", line 1740, in return_env
[self.VCIncludes,
^^^^^^^^^^^^^^^
File "C:UserstuankAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagessetuptoolsmsvc.py", line 1282, in VCIncludes
return [join(self.si.VCInstallDir, 'Include'),
^^^^^^^^^^^^^^^^^^^^
File "C:UserstuankAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagessetuptoolsmsvc.py", line 840, in VCInstallDir
raise distutils.errors.DistutilsPlatformError(msg)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.3 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Перейти к содержанию
На чтение 1 мин Просмотров 532 Опубликовано 05.12.2022
Ошибка «error: metadata-generation-failed» при установке модуля для Python 3.11. Как исправить эту ошибку и установить модуль для Питон.
При установке модуля pygame для Python возникает следующая ошибка:
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
Как исправить ошибку «error: metadata-generation-failed»
Ошибка при установке модуля, в данном случае это pygame, возникает по причине не совместимости версии Python и модуля pygame. В моем случае версия Питона самая свежая на момент написания статьи — 3.11, с которой конфликтует модуль pygame.
Для того чтобы установить модуль pygame на Python 3.11, нужно ввести следующую команду:
pip install pygame --pre
Тем самым мы устанавливаем предварительную версию модуля. По умолчанию pip находит только стабильные версии.
После чего модуль pygame будет успешно установлен.
Дмитрий Монакс
Автор блога SEO.Monaks.ru
Продвижение сайтов и контекстная реклама с 2009 года
Консультирую по вопросам поисковой оптимизации, выполняю SEO аудиты, а также другие работы связанные с поисковой оптимизацией.
По сотрудничеству в раздел — «КОНТАКТЫ»
Мы понимаем, что всплывающие окна – это зло =( Но пока по-другому не получается предупредить вас об использовании куки-файлов на нашем сайте. Так мы с каждым днем будем становиться лучше и полезнее для вас!
When installing Python packages using the pip install
command, you might come across the “metadata-generation-failed” error.
This error occurs because the setup.py
file in the package cannot be executed properly. This guide will provide a detailed overview of the possible causes and their solutions.
The main reasons for this error include:
- Outdated pip, setuptools, and wheel packages
- Unmaintained package
- Incompatibility with the latest Python version
- Unmet external dependencies
When running the pip install
command, Python’s build systems use the setuptools
and wheel
packages during the process. If these packages are outdated, the error might appear. To upgrade these build tools to their latest versions, follow these steps:
Step 1: Check the current versions of pip, setuptools, and wheel
First, verify the current versions of pip
, setuptools
, and wheel
installed on your system. Run the following commands:
For Unix/macOS:
python3 -m pip --version
python3 -m setuptools --version
python3 -m wheel --version
For Windows:
py -m pip --version
py -m setuptools --version
py -m wheel --version
Step 2: Upgrade the build tools
Next, upgrade the build tools to their latest versions by running these commands:
For Unix/macOS:
python3 -m pip install --upgrade pip setuptools wheel
For Windows:
py -m pip install --upgrade pip setuptools wheel
Step 3: Verify the updated versions
After upgrading the build tools, run the same commands used in Step 1 to ensure that the versions have been updated.
Step 4: Reinstall the package
With the build tools updated, try installing the package again to see if the error is resolved.
2. Find an Alternative Package if the Original is Unmaintained
Some packages are no longer maintained, which can lead to errors when changes are introduced in the setuptools
or wheel
packages. In such cases, you need to find an alternative package that is actively maintained.
Step 1: Check the package’s last update
First, visit the package’s repository or homepage and check its last update date. If it hasn’t been updated in a while, it might be unmaintained.
Step 2: Search for alternative packages
Look for alternative packages that provide similar functionality. You can search for alternatives on platforms like PyPI, GitHub, or libraries.io.
Step 3: Compare the alternatives
Compare the alternative packages based on factors such as:
- Popularity and user ratings
- Number of downloads
- Frequency of updates
- Compatibility with your Python version and other dependencies
- Community support and documentation
Step 4: Install the alternative package
Once you have chosen an alternative package, install it using the pip install
command.
3. Check Compatibility with the Latest Python Version
Some packages might not be compatible with the latest version of Python, causing errors during installation. Follow these steps to resolve compatibility issues:
Step 1: Verify your Python version
Check your current Python version by running the following command:
For Unix/macOS:
python3 --version
For Windows:
py --version
Step 2: Check the package’s supported Python versions
Visit the package’s repository, homepage, or documentation to find the Python versions it supports. You can also check the package’s setup.py
file or the pyproject.toml
file to find this information.
Step 3: Install a compatible Python version
If your Python version is incompatible with the package, consider installing a compatible version. You can download different Python versions from the official Python website.
Step 4: Create a virtual environment
It’s a good practice to create a virtual environment for your project, especially when using different Python versions or dependency configurations. To create a virtual environment, run the following command:
For Unix/macOS:
python3 -m venv my_project_env
For Windows:
py -m venv my_project_env
Replace my_project_env
with the desired name for your virtual environment.
Step 5: Activate the virtual environment
Activate the virtual environment by running the following command:
For Unix/macOS:
source my_project_env/bin/activate
For Windows:
my_project_envScriptsactivate.bat
Step 6: Install the package in the virtual environment
With the virtual environment activated, install the package using the pip install
command.
4. Ensure External Dependencies are Met
Some Python packages require external dependencies to be met for successful installation. Follow these steps to ensure all dependencies are in place:
Step 1: Check the package’s requirements
Visit the package’s homepage or documentation to find any external dependencies required for installation. You can also check the package’s README.md
file, setup.py
file, or requirements.txt
file for this information.
Step 2: Install the required dependencies
Install the required dependencies using the appropriate package manager for your operating system. For example, on Unix-based systems, you might use apt-get
, yum
, or brew
, while on Windows, you might use choco
.
Step 3: Verify the installation of dependencies
After installing the required dependencies, verify their installation using the appropriate commands or tools for your operating system.
Step 4: Reinstall the package
With all the external dependencies installed, try installing the package again using the pip install
command.
Additional Tips
If you still encounter the “metadata-generation-failed” error, consider these additional tips:
- Consult the package’s issue tracker: Check the package’s issue tracker (e.g., GitHub issues) to see if other users have encountered the same error and if any solutions have been provided.
- Reach out to the package maintainers: If you cannot find a solution, consider reaching out to the package maintainers for help. You can usually find their contact information in the package documentation or repository.
- Browse community forums: Search for solutions in Python community forums, such as Stack Overflow, Reddit, or the Python mailing list. You might find useful information from users who have faced similar issues.
Conclusion
The “metadata-generation-failed” error in pip can be caused by various factors, such as outdated build tools, unmaintained packages, incompatibility with the latest Python version, or unmet external dependencies. By addressing these issues, you should be able to resolve the error and successfully install your desired Python package.