Just a reminder to whom google this error and come here.
Let’s say I get this error:
$ python3 example.py
Traceback (most recent call last):
File "example.py", line 7, in <module>
import aalib
ModuleNotFoundError: No module named 'aalib'
Since it mentions aalib
, I was thought to try aalib
:
$ python3.8 -m pip install aalib
ERROR: Could not find a version that satisfies the requirement aalib (from versions: none)
ERROR: No matching distribution found for aalib
But it actually wrong package name, ensure pip search
(service disabled at the time of writing), or google, or search on pypi site to get the accurate package name:
Then install successfully:
$ python3.8 -m pip install python-aalib
Collecting python-aalib
Downloading python-aalib-0.3.2.tar.gz (14 kB)
...
As pip --help
stated:
$ python3.8 -m pip --help
...
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
To have a systematic way to figure out the root causes instead of rely on luck, you can append -vvv
option of pip
command to see details, e.g.:
$ python3.8 -u -m pip install aalib -vvv
User install by explicit request
Created temporary directory: /tmp/pip-ephem-wheel-cache-b3ghm9eb
Created temporary directory: /tmp/pip-req-tracker-ygwnj94r
Initialized build tracking at /tmp/pip-req-tracker-ygwnj94r
Created build tracker: /tmp/pip-req-tracker-ygwnj94r
Entered build tracker: /tmp/pip-req-tracker-ygwnj94r
Created temporary directory: /tmp/pip-install-jfurrdbb
1 location(s) to search for versions of aalib:
* https://pypi.org/simple/aalib/
Fetching project page and analyzing links: https://pypi.org/simple/aalib/
Getting page https://pypi.org/simple/aalib/
Found index url https://pypi.org/simple
Getting credentials from keyring for https://pypi.org/simple
Getting credentials from keyring for pypi.org
Looking up "https://pypi.org/simple/aalib/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/aalib/ HTTP/1.1" 404 13
[hole] Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://pypi.org/simple/aalib/: 404 Client Error: Not Found for url: https://pypi.org/simple/aalib/ - skipping
Given no hashes to check 0 links for project 'aalib': discarding no candidates
ERROR: Could not find a version that satisfies the requirement aalib (from versions: none)
Cleaning up...
Removed build tracker: '/tmp/pip-req-tracker-ygwnj94r'
ERROR: No matching distribution found for aalib
Exception information:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 357, in run
resolver.resolve(requirement_set)
File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 281, in _get_abstract_dist_for
req.populate_link(self.finder, upgrade_allowed, require_hashes)
File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 249, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 926, in find_requirement
raise DistributionNotFound(
pip._internal.exceptions.DistributionNotFound: No matching distribution found for aalib
From above log, there is pretty obvious the URL https://pypi.org/simple/aalib/
404 not found. Then you can guess the possible reasons which cause that 404, i.e. wrong package name. Another thing is I can modify relevant python files of pip modules to further debug with above log. To edit .whl
file, you can use wheel
command to unpack
and pack
.
Sometimes you get an error when you’re trying to install a Python package
using pip. It looks like this:
Could not find a version that satisfies the requirement (from versions:)
No matching distribution found for
Some probable reasons for this error are:
-
PyPI server isn’t responding to your requests. It can happen either because
the PyPI server is down or because it has blacklisted your IP address. This
happened to me once when I was trying installing packages on a server.
This can be fixed by using a proxy with pip. See the solution below. -
You’re running an older pip (especially on Mac). This can be fixed by
upgrading your pip.
See this post on Stack Overflow.
Thanks to Anupam Jain who pointed this in a comment. -
The package you’re trying to install is not available for your Python version.
-
The package is not available for your operating system. This is a rare case
and only happens when the package is not pure-Python, i.e. it’s been
partially written in C or Cython. Such a package needs to be compiled for
every operating system (Windows/Mac/Linux) and architecture (32-bit/64-bit).
Suppose a package has only been compiled for Windows 64-bit, then you’ll get
this error if you try to install it on Windows 32-bit, or any other
OS. -
The package is not present on PyPI server. In this case pip will not work. So
you’ll have to download and install the package manually from Github or wherever
it is available.
Solution¶
I had this issue because PyPI server had blacklisted the IP
of my hosting provider, the obvious solution was to make pip
install via a proxy.
But to see if that’s also the case with you, you can test it like this:
$ curl https://pypi.org
The requestors Network has been blacklisted due to excessive request volume.
If you are a hosting customer, please contact your hosting company's support.
If you are the hosting company, please contact infrastructure-staff@python.org to resolve
If you see the message similar to above, that means your IP has also been
blacklisted by https://pypi.org.
If you don’t see this message then the reason for the pip error could be that you’re using
an older version. See this post on Stack Overflow
for a solution.
Anyways, this can be fixed by using a proxy with pip.
Supplying a proxy address to pip
is easy:
$ pip install -r requirements.txt --proxy address:port
Above, address
and port
are IP address and port of the proxy.
To find proxies, just search Google for proxy list.
Other things that I tried¶
These are some other things that I tried to get rid of this issue.
Although they didn’t work for me, but they might work for you.
- Changing DNS resolver of my server.
This makes sense if your server’s DNS resolver can’t find PyPI servers. - Reconfiguring SSL, reinstalling CA certificates.
This makes sense if you don’t have updated CA certificates which are used by
PyPI servers. - Downloading packages using
wget
.
This is an alternative way to install Python packages. Download them viawget
and then install them usingpython setup.py install
. In my case, the server was
blacklisted by PyPI so I was getting a 403 Forbidden error. - Downloading packages using
curl
.
Alternative towget
. In my case I didn’t get a 403 error but rather it just
created invalid tarball files, instead of actually downloading them. - Downloading packages using
git
orhg
.
If your desired packages havegit
orhg
repositories that you can clone, this
is a good workaround.
Ah I see the Python versions case specifically is now handled, via #9708. Example output (when using Python 3.7 and a package that has dropped support for 3.7):
$ pip install ipython==8.5.0
ERROR: Ignored the following versions that require a different python version: 8.0.0 Requires-Python >=3.8; 8.0.0a1 Requires-Python >=3.8; 8.0.0b1 Requires-Python >=3.8; 8.0.0rc1 Requires-Python >=3.8; 8.0.1 Requires-Python >=3.8; 8.1.0 Requires-Python >=3.8; 8.1.1 Requires-Python >=3.8; 8.2.0 Requires-Python >=3.8; 8.3.0 Requires-Python >=3.8; 8.4.0 Requires-Python >=3.8; 8.5.0 Requires-Python >=3.8
ERROR: Could not find a version that satisfies the requirement ipython==8.5.0 (from versions: 0.10, 0.10.1, 0.10.2, 0.11, 0.12, 0.12.1, 0.13, 0.13.1, 0.13.2, 1.0.0, 1.1.0, 1.2.0, 1.2.1, 2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 3.0.0, 3.1.0, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 4.0.0b1, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.1.0rc1, 4.1.0rc2, 4.1.0, 4.1.1, 4.1.2, 4.2.0, 4.2.1, 5.0.0b1, 5.0.0b2, 5.0.0b3, 5.0.0b4, 5.0.0rc1, 5.0.0, 5.1.0, 5.2.0, 5.2.1, 5.2.2, 5.3.0, 5.4.0, 5.4.1, 5.5.0, 5.6.0, 5.7.0, 5.8.0, 5.9.0, 5.10.0, 6.0.0rc1, 6.0.0, 6.1.0, 6.2.0, 6.2.1, 6.3.0, 6.3.1, 6.4.0, 6.5.0, 7.0.0b1, 7.0.0rc1, 7.0.0, 7.0.1, 7.1.0, 7.1.1, 7.2.0, 7.3.0, 7.4.0, 7.5.0, 7.6.0, 7.6.1, 7.7.0, 7.8.0, 7.9.0, 7.10.0, 7.10.1, 7.10.2, 7.11.0, 7.11.1, 7.12.0, 7.13.0, 7.14.0, 7.15.0, 7.16.0, 7.16.1, 7.16.2, 7.16.3, 7.17.0, 7.18.0, 7.18.1, 7.19.0, 7.20.0, 7.21.0, 7.22.0, 7.23.0, 7.23.1, 7.24.0, 7.24.1, 7.25.0, 7.26.0, 7.27.0, 7.28.0, 7.29.0, 7.30.0, 7.30.1, 7.31.0, 7.31.1, 7.32.0, 7.33.0, 7.34.0)
ERROR: No matching distribution found for ipython==8.5.0
The case I saw more recently that still had confusing UX, was for a platform mismatch (a user trying to install a Windows package on Linux):
moneymeets/python-poetry-buildpack#49
To Solve this Could not find a version that satisfies the requirement You need to update your pip and setup tools and that will resolve this error.
Contents
- Solution 1: Just update the pip
- Solution 2: Use this command.
- Solution 3: For Requirements.txt
- Solution 4: Make Sure the Right Python version Using
- Frequently Asked Questions
- Summary
Solution 1: Just update the pip
You just need to update the pip and your error will be resolved. Just follow this command.
If you are a windows user Then run this command.
python -m pip install --upgrade pip
Mac users who use pip and PyPI
curl https://bootstrap.pypa.io/get-pip.py | python
And then also upgrade setuptools after doing the above.
pip install --upgrade setuptools
Solution 2: Use this command.
On Debian-based systems, I’d try
apt-get update && apt-get upgrade python-pip
Red Hat Linux-based systems:
yum update python-pip
On Mac:
sudo easy_install -U pip
Solution 3: For Requirements.txt
If You are trying to install Requirements.txt and you are facing this error then You need to use -r in the command line. Just Like This.
pip install -r requirements.txt
And now, Your error will be resolved.
Solution 4: Make Sure the Right Python version Using
Please Make Sure You are Using Right Python Version In your Command line. If You have installed Python 3 and You are trying to use Python2 then You might face this error.
python3 -m pip install <your_pkg>
Frequently Asked Questions
- How to solve Could not find a version that satisfies the requirement error?
to solve Could not find a version that satisfies the requirement error If You are trying to install Requirements.txt and you are facing this error then You need to use -r in the command line. Just Like This: pip install -r requirements.txt And now, Your error will be resolved.
- Could not find a version that satisfies the requirement
to solve Could not find a version that satisfies the requirement error Please Make Sure You are Using Right Python Version In your Command line. If You have installed Python 3 and You are trying to use Python2 then You might face this error: python3 -m pip install <your_pkg>
Summary
The solution is simple you just need to update your PIP to the very latest version and then update setuptools will resolve this error. Comment below if you are still facing this error.
Also, Read
- pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’s not in your path
I have seen a few related questions, and I’ve tried all of their recommendations:
- I’m using anaconda, so I downgraded from 3.7 to 3.6
- I upgraded pip using curl https://bootstrap.pypa.io/get-pip.py | sudo python
- I installed the latest version of openssl (1.1.1)
- I updated all Anaconda libraries
- I am connected to the Internet (obviously, since I’m posting here) and not behind a firewall.
And yet, every time I run «pip install » or «pip install ==» I get the following error:
ERROR: Could not find a version that satisfies the requirement (from versions: none)
ERROR: No matching distribution found for
I’m on a Mac, Mojave v10.14.4
I recently installed prodigy.ai, which seemed to replace a bunch of packages with (perhaps) older versions, but I still cannot figure out how to fix this issue. The one thing I haven’t tried is uninstalling Anaconda and reinstalling it.
Thanks for any help on this.
asked Apr 26, 2019 at 18:10
11
Yes, it happened to me also.
A common case in this procedure is to check if you have not made a typo when entering the package name.
answered Jun 18, 2019 at 9:15
simhumilecosimhumileco
6577 silver badges14 bronze badges
Collecting numpy
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /packages/5c/28/32ca028c2dcaa3f180dcc59266d6856d3e24f63ca96b8fc4af9bdbd4ae04/numpy-1.17.4-cp38-cp38-win32.whl
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /packages/5c/28/32ca028c2dcaa3f180dcc59266d6856d3e24f63ca96b8fc4af9bdbd4ae04/numpy-1.17.4-cp38-cp38-win32.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /packages/5c/28/32ca028c2dcaa3f180dcc59266d6856d3e24f63ca96b8fc4af9bdbd4ae04/numpy-1.17.4-cp38-cp38-win32.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /packages/5c/28/32ca028c2dcaa3f180dcc59266d6856d3e24f63ca96b8fc4af9bdbd4ae04/numpy-1.17.4-cp38-cp38-win32.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /packages/5c/28/32ca028c2dcaa3f180dcc59266d6856d3e24f63ca96b8fc4af9bdbd4ae04/numpy-1.17.4-cp38-cp38-win32.whl
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/5c/28/32ca028c2dcaa3f180dcc59266d6856d3e24f63ca96b8fc4af9bdbd4ae04/numpy-1.17.4-cp38-cp38-win32.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))