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

1. Upgrade Your Build Tools

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:


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.


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.