Python Can't Install New Packages from PyPI

In this tutorial, we'll deep dive into several reasons why you can't install new packages from PyPI.

This post will describe the different kinds of errors and their solution in Python - tested in Linux and Windows.

Documentation about installing Python packages with Pip: pip install

Reason 1: Dependency Error - "Installing build dependencies ... error"

The first reason that prevents you from installing the latest package versions is dependency error.

In the example below we are trying to install black==20.8b1

pip install black

but the installation fails due to next error:

 pip install black==20.8b1
Collecting black==20.8b1
  Using cached black-20.8b1.tar.gz (1.1 MB)
  Installing build dependencies ... error

A possible solution is to check the latest versions of the package and to install one which is:

  • supported by your version
  • doesn't have dependency issues
pip install black==19.10b0

Reason 2: Upgrade pip/setuptools before installation of new packages

In case of errors or getting the wrong package version you can try to upgrade your package manager.

In case of a pip:

python -m pip install --upgrade pip

Latest package versions might require features which are present in the latest versions of pip, conda etc.

Some package require also package setuptools which can be upgraded by:

pip install setuptools --upgrade

or

pip install -U setuptools

Reason 3: Package is not supported by Python version

When a new Python version is released (i.e. 3.8, 3.9 etc) the package needs updates in order to support it.

You will face errors like:

running dist_info
        running build_src
        build_src
        building py_modules sources
        creating build
        creating build\src.win-amd64-3.9
        creating build\src.win-amd64-3.9\numpy
        creating build\src.win-amd64-3.9\numpy\distutils
        building library "npymath" sources
        error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

or

error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)

or

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

If you install a brand new version there is a high probability that many packages will fail to be installed.

There are two things you can do in this case:

  1. Verify the latest stable and secure Python version from:

You can find - end-of-life, security and bugfix. Take the latest security one.

  1. Check if the problematic package support your Python version:

Bonus for Windows: Windows Pip version - pipwin

Pipwin is advertised as:

pipwin is a complementary tool for pip on Windows. pipwin installs unofficial python package binaries for windows

It can help if you use Windows and Python:

pip install pipwin
pipwin install black