pip install' fails for every package (Could not find a version that satisfies the requirement)
Upgrade pip as follows:
curl https://bootstrap.pypa.io/get-pip.py | python
Note: You may need to use sudo python
above if not in a virtual environment.
What's happening:
Python.org sites are stopping support for TLS versions 1.0 and 1.1. This means that Mac OS X version 10.12 (Sierra) or older will not be able to use pip unless they upgrade pip as above.
(Note that upgrading pip via pip install --upgrade pip
will also not upgrade it correctly. It is a chicken-and-egg issue)
This thread explains it (thanks to this Twitter post):
Mac users who use pip and PyPI:
If you are running macOS/OS X version 10.12 or older, then you ought
to upgrade to the latest pip (9.0.3) to connect to the Python Package
Index securely:curl https://bootstrap.pypa.io/get-pip.py | python
and we recommend you do that by April 8th.
Pip 9.0.3 supports TLSv1.2 when running under system Python on macOS <
10.13. Official release notes: https://pip.pypa.io/en/stable/news/
Also, the Python status page:
Completed - The rolling brownouts are finished, and TLSv1.0 and TLSv1.1 have been disabled. Apr 11, 15:37 UTC
Update - The rolling brownouts have been upgraded to a blackout, TLSv1.0 and TLSv1.1 will be rejected with a HTTP 403 at all times.
Apr 8, 15:49 UTC
Lastly, to avoid other install errors, make sure you also upgrade setuptools after doing the above:
pip install --upgrade setuptools
Python Pip: pip install cannot find a version that satisfies a requirement - despite present in pyproject.toml
Main Error
TLDR; Pip tries to resolve dependencies with TestPypi, but they are in another index (Pypi). Workarounds at end of answer.
The fact that I am publishing to TestPypi is the reason this has happened. I will explain why what I did made this error appear, and then I will show how you, from the future, may solve this.
Difference between Pypi and TestPypi
Pypi is the Python Package Index. It's a giant index of Python packages one may install from with pip install
.
TestPypi is the Python Package Index designated for testing and publishing without touching the real Package Index. It can be useful in times when learning how to publish a package. The main difference is that it is a completely separate repository. Therefore, what's on TestPypi may not be exactly what's on Pypi.
My research was limited, so if I confused anyone, the main difference is that they are two different Package Indexes. One was made for testing purposes.
I published my package to TestPypi and set my pip install to install from that repository. Not Pypi, but TestPypi.
Why dependency resolution failed
When I defined my project's dependencies, I defined them based off of their Pypi presences. Most dependencies are present in Pypi. Not TestPypi. This meant that when I asked for my package from TestPypi, pip only looked at TestPypi, and the pip installer workflow fell out to a pattern like this:
0.5. Set fetching repository to TestPypi and Not Pypi.
- Pull package from TestPypi
- Install and examine dependencies
- Find first dependency (e.g. Beautifulsoup4)
- Pull dependency from TestPypi
- Successfully install Beautifulsoup4
-. This is because beautifulsoup4 is actually present in the TestPypi. - Move on to another dependency (e.g. rich)
- Fail to pull from TestPypi
-. Rich is not present in TestPypi. - Return dependency not found.
Why some dependencies oddly worked
As you see in workflow step 5., the beautifulsoup4 package was found on the TestPypi. (Someone had put it up there).
image to TestPypi page with beautifulsoup4
However, as you see in step 7., Rich is not found on the TestPypi index. This issue occurs because I set my repoistiroy to install from TestPypi because my that is where my package was held. This caused pip to use TestPypi. for every single dependency as well.
How I got around it.
I got around it by using TestPypi to verify accurate build artifact publishing, and then I jumped to Normal Pypi to test installation and dependency installation.
Workarounds
Install from TestPypi
python3 -m pip install -i https://test.pypi.org/simple/ <package name>
Install from Pypi (by default)
python3 -m pip install <package name>
Install package from TestPypi but dependencies from Pypi
The Python Docs explains this very well.
If you want to allow pip to also download packages from PyPI, you can specify --extra-index-url to point to PyPI. This is useful when the package you’re testing has dependencies:
python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ your-package
Pip could not find a version that satisfies the requirement
From PyPI, jurigged
is only supported as of Python >= 3.8 (see also here)
pip
doesn't find anything to install because you do not meet the requirements.
Upgrade to Python >= 3.8 and do the same: pip install jurigged
Could not find a version that satisfies the requirement evaluate
Look at the left side-bar on PyPi package page for evaluate
. Near the bottom is the "Programming Language" section. It lists availability for Python version 3.7 to 3.10.
You will need to create a new environment with one of those versions of Python.
Cannot install latest version of Numpy (1.22.3)
Please check your Python version. Support for Python 3.7 is dropped since Numpy 1.22.0 release. [source]
Related Topics
"Pip Install Unroll": "Python Setup.Py Egg_Info" Failed With Error Code 1
How to Print a Single Backslash
Using @Property Versus Getters and Setters
How to Step Through Python Code to Help Debug Issues
How to Check If a String Represents an Int, Without Using Try/Except
How to Fix "Runtimeerror: Package Fails to Pass a Sanity Check" For Numpy and Pandas
Finding Local Ip Addresses Using Python'S Stdlib
Find the Current Directory and File'S Directory
String Comparison in Python: Is Vs. ==
Efficient Way to Rotate a List in Python
Pandas: How to Easily Share a Sample Dataframe Using Df.To_Dict()
Sort a List by Multiple Attributes
Annotate Bars With Values on Pandas Bar Plots
"Unicode Error "Unicodeescape" Codec Can't Decode Bytes... Cannot Open Text Files in Python 3