Last updated: Apr 10, 2024
Reading timeยท5 min

To solve the "Preparing metadata (pyproject.toml) did not run successfully" error:
pip, setuptools and wheel.pip install command with the --pre option.Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error ร Preparing metadata (pyproject.toml) did not run successfully. โ exit code: 1
If you got the error when trying to install PyQt5 on macOS:
brew install qt5 command to install qt5.qmake is located to your PATH environment
variable.export PATH=$PATH:<path_to_qmake>
qmake, try running the following command, which will symlink the qt5 binaries and enable you to access qmake at the command line without the need to edit your PATH.brew link qt5 --force
pip, setuptools and wheelFirst, try to upgrade your versions of pip, setuptools and wheel.
pip install wheel setuptools pip --upgrade pip3 install wheel setuptools pip --upgrade # ๐๏ธ If you don't have `pip` in your PATH environment variable python -m pip install wheel setuptools pip --upgrade python3 -m pip install wheel setuptools pip --upgrade py -m pip install wheel setuptools pip --upgrade

pip install command after you have upgraded pip, setuptools and wheel.--use-deprecated-legacy option when installingIf that didn't help, try running the pip install command with the
--use-deprecated-legacy option.
pip install numpy --use-deprecated=legacy-resolver pip3 install numpy --use-deprecated=legacy-resolver python -m pip install numpy --use-deprecated=legacy-resolver python3 -m pip install numpy --use-deprecated=legacy-resolver py -m pip install numpy --use-deprecated=legacy-resolver # -------------------------------------------------------------- # ๐๏ธ Set to backtrack-on-build-failures for older versions of pip pip install numpy --use-deprecated=backtrack-on-build-failures pip3 install numpy --use-deprecated=backtrack-on-build-failures python -m pip install numpy --use-deprecated=backtrack-on-build-failures python3 -m pip install numpy --use-deprecated=backtrack-on-build-failures

numpy with the name of the package you're trying to install.The --use-deprecated option allows us to use the old resolver behavior when
installing modules.
If the suggestions didn't help, read toward the end of your error message.
It might contain information such as:
"RuntimeError: Cannot install on Python version 3.11.0; only versions >=3.7,<3.11 are supported."
"RuntimeWarning: NumPy X.Y.Z may not yet support Python 3.11"
In this case, you can try to:
pip install requests==2.28.0.Your error message might also contain a missing package you have to install, e.g. "ModuleNotFoundError: No module named 'X'" or "ImportError: cannot import name 'X'".
If that's the case, you have to pip install the package from the error message
before installing the other package.
pip install <package_from_error_message> pip3 install <package_from_error_message>
Another common cause of the error is misspelling the name of the package and trying to install some broken, obsolete module by mistake.
pip install command with the --pre optionIf none of the suggestions helped, try running the pip install command with
the --pre option.
pip install scikit-learn --pre pip3 install scikit-learn --pre python -m pip install scikit-learn --pre python3 -m pip install scikit-learn --pre py -m pip install scikit-learn --pre

--pre option makes it so pip includes pre-release and development versions of the package. By default pip only finds stable versions.If the suggestions didn't help, try installing another version of the package.
pip install requests==

The output contains a tuple of all of the versions of the package from the oldest to the most recent version.
Pick another version of the package and try installing it. Here is an example.
pip install requests==2.28.0 pip3 install requests==2.28.0
If you use Anaconda, follow the instructions in my Install a specific package version using conda article.
--extra-index option when installing scikit-learnIf you got the error while
trying to install scikit-learn, try
running the command with the --pre and --extra-index options.
pip install --pre --extra-index https://pypi.anaconda.org/scipy-wheels-nightly/simple scikit-learn
The command installs the nightly build of scikit-learn where bugs might have
been fixed.
The most common cause of the error is having a Python version that is not supported by the package you're trying to install.
The error is sometimes caused when the package you are trying to install doesn't
have available wheels for your version of Python.
You can check your Python version with the python --version command.
python --version

You can check if a package has wheels available for a specific Python version in
the Download files section of the
package's pypi page.
cp310 in the name of a file under "Built Distributions" means Python version 3.10 is supported for the specific operating system.If the .whl files are not available for your version of Python, you can
download an older version.
If that didn't work, you can download a specific Python version that is supported by the package if the package doesn't support the latest Python version.
Different versions are available in the "Looking for a specific release" table.

Make sure to tick the following options if you get prompted:
If that didn't help and you don't already have a virtual environment, try creating one.
pip install command with the virtual environment active.# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ Install the specific package in the virtual environment pip install requests
If the python3 -m venv venv command fails, try one of the following commands:
python -m venv venvpy -m venv venvMake sure to use the correct command to activate your virtual environment depending on your operating system and your shell.
Your virtual environment will use the version of Python that was used to create it.
If none of the suggestions helped, try running the pip install command in
verbose mode.
pip install requests -vvv pip3 install requests -vvv python -m pip install requests -vvv
The -v option stands for verbose mode and can be used up to 3 times.
When the pip install command is run in verbose mode, the command shows more
output and how the error occurred.