找不到满足要求的版本 <package>
Could not find a version that satisfies the requirement <package>
我正在使用以下 requirements.txt
文件在 Ubuntu 12.04 中安装几个 Python 软件包:
numpy>=1.8.2,<2.0.0
matplotlib>=1.3.1,<2.0.0
scipy>=0.14.0,<1.0.0
astroML>=0.2,<1.0
scikit-learn>=0.14.1,<1.0.0
rpy2>=2.4.3,<3.0.0
这两个命令:
$ pip install --download=/tmp -r requirements.txt
$ pip install --user --no-index --find-links=/tmp -r requirements.txt
(第一个下载包,第二个安装)。
进程频繁停止并出现错误:
Could not find a version that satisfies the requirement <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2)) (from versions: )
No matching distribution found for <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2))
我手动修复的是:
pip install --user <package>
然后 运行 再次执行第二个 pip install
命令。
但这只适用于那个特定的包。当我再次 运行 第二个 pip install
命令时,该过程现在停止抱怨 另一个 需要的包,我需要再次重复该过程,即:安装手动新建所需包(使用上面的命令),然后 运行 第二个 pip install
命令。
到目前为止,我不得不手动安装 six
、pytz
、nose
,现在它抱怨需要 mock
。
有没有办法告诉 pip
自动安装 所有 需要的依赖项,这样我就不必一个一个地手动安装?
Add:这只发生在 Ubuntu 12.04 顺便说一句。在 Ubuntu 14.04 中,应用于 requirements.txt
文件的 pip install
命令没有问题。
这种方法(将所有依赖项都放在目录中而不是从索引中下载)仅在目录包含所有包时才有效。因此,该目录应包含所有依赖项以及这些依赖项所依赖的所有包(例如,six
、pytz
等)。
因此您应该手动将它们包含在 requirements.txt
中(以便第一步明确下载它们)或者您应该使用 PyPI 安装所有包然后 pip freeze > requirements.txt
来存储所有需要的包的列表.
尝试使用以下命令通过 powershell 安装 flask。
pip install --isolated Flask
这将允许安装避免环境变量和用户配置。
经过2个小时的搜索,我找到了一种只需一行命令即可修复它的方法。您需要知道软件包的版本(只需搜索 PACKAGE 版本)。
命令:
python3 -m pip install --pre --upgrade PACKAGE==VERSION.VERSION.VERSION
并非总是如此,但在某些情况下,包已经存在。例如-getpass。它未被 "pip list" 列出,但可以导入和使用:
如果我尝试 pip install getpass 我会收到以下错误:
"Could not find a version that satisfies the requirement getpass"
我已经安装了 python3 但我在 /usr/bin/python 中的 python 仍然是旧的 2.7 版本
这有效(<pkg>
在我的例子中是 pyserial
):
python3 -m pip install <pkg>
使用命令提示符,然后 select 运行 作为管理员。
升级pip版本
要升级 PIP,请键入此命令,然后按 Enter:
python.exe -m pip install --upgrade pip
返回 python 路径 C:\Users\Jack\AppData\Local\Programs\Python\Python37\Scripts
输入 jupyter notebook
您将被重定向到 http://localhost:8888/undefined/tree
Jupyter 主页
希望对您有所帮助!!!!!!!!!!!!
以下命令对我有用 -
python -m pip install flask
我在 anaconda (python 3.7) 的 Windows 10 上安装 awscli
时出现此错误。
在排查问题的同时,我去了答案 and then to 。最后发现我需要安装库 PyOpenSSL
、cryptography
、enum34
、idna
和 ipaddress
。安装这些后(仅使用 pip install
命令),我能够安装 awscli
.
如果您在工作场所遇到这个问题。这可能是适合您的解决方案。
pip install -U <package_name> --user --proxy=<your proxy>
虽然它并没有真正回答这个具体问题。其他人也因为这个错误得到了同样的错误信息。
对于那些像我这样的人最初忘记了-r
:使用pip install -r requirements.txt
-r
是必不可少的命令。
原答案:
只是提醒google这个错误的人过来。
假设我收到此错误:
$ python3 example.py
Traceback (most recent call last):
File "example.py", line 7, in <module>
import aalib
ModuleNotFoundError: No module named 'aalib'
既然提到了aalib
,我就想试试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
但实际上错误的包名,确保pip search
(service disabled at the time of writing), or google, or search on pypi site得到准确的包名 :
然后安装成功:
$ python3.8 -m pip install python-aalib
Collecting python-aalib
Downloading python-aalib-0.3.2.tar.gz (14 kB)
...
如pip --help
所述:
$ python3.8 -m pip --help
...
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
要有系统的方法找出根本原因而不是靠运气,您可以在 pip
命令后附加 -vvv
选项以查看详细信息,例如:
$ 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
从上面的日志中,很明显 URL https://pypi.org/simple/aalib/
404 未找到。那么你就可以猜出导致404的可能原因,即错误的包名。另一件事是我可以修改 pip 模块的相关 python 文件以进一步调试上述日志。要编辑 .whl
文件,您可以 .
在 MacO 上,在略有不同的情况下出现相同的错误。显然 setuptools 版本超过 45 可以暴露一些问题,这个命令让我过去了:
pip3 install setuptools==45
从 pypi.org.
安装 Pip
pip install -U -i https://pypi.org/simple package
一个可能的错误,pip 包需要 python 你没有使用的解释器。
我 运行 遇到同样的问题,只有当我从我的 Docker 图像(或 Docker 文件)发出 运行 命令时才会发生。终于在几个小时后,我通过更新 python 解释器设法解决了这个问题。指出我的 pip-package 需要 python>=3,7 但我的 Docker 图像使用的是 python 3.6.
提示:要检查您是否有类似问题,只需检查 pip 包要求和您的 python 版本。私有 pip 包解释器要求写在 setup.py 或 setup.cfg 中。 Public pip 包通常托管在 pypi.org 中,您可以在其中使用浏览器检查解释器要求。要检查您的 python 解释器版本,只需在您的控制台中编写例如 python --version 或 python3 --version
一般问题描述
正如其他答案指出的那样,您可能还有其他不满足的要求,这就是为什么 pip 找不到适合您的软件包版本的原因。所有要求都写在 pip 包文档中,可以从 https://pypi.org/project/graphene-django/your-package
轻松阅读
如果您发现该软件包的其他版本可用,请在 google 中搜索
例如使用那个
我在使用 glob 时遇到错误,所以我改用 glob2
当我失去互联网连接时,出现了这个错误。
如果包是本地的,不要遗漏相对路径。
例如
pip install ./<pkg>
终于在我的案例中起作用了,而
pip install <pkg>
产量:
ERROR: Could not find a version that satisfies the requirement <pkg> (from versions: none)
ERROR: No matching distribution found for <pkg>
由于这是一个很烦人的问题,可能会长期困扰初学者,所以我在这里写一个完整的公会。
if you are running pip install PACKAGE
or python -m pip install PACKAGE
, and a no matching version found
error reported, here's how to solve the problem.
在浏览器上搜索你的包,比如我的包是pycypto
,我这里搜索pycypto pypi
找到你的包,打开pypi上的link,点击下载文件
打开一个pythonshell,导入你安装的任意一个包,比如我之前安装过Pillow
>>> import PIL
>>> PIL.__path__
['/Applications/MAMP/htdocs/canvas/src/zzd/env/lib/python3.7/site-packages/PIL']
PACKAGE.__path__
函数将为您提供 side packages
所有包都应进入的路径。
加上:
如果您不知道之前安装了哪些软件包,运行 pip list
获取已安装软件包的列表。
- 获取路径后,打开一个shell,cd到路径
cd /Applications/MAMP/htdocs/canvas/src/zzd/env/lib/python3.7/site-packages/
open
解压下载的文件,拖入site-packages
.
cd 进入下载目录,运行 setup.py
安装
cd pycrypto-2.6.1
python setup.py install
那么你应该可以导入并使用python中的包了。
我正在使用以下 requirements.txt
文件在 Ubuntu 12.04 中安装几个 Python 软件包:
numpy>=1.8.2,<2.0.0
matplotlib>=1.3.1,<2.0.0
scipy>=0.14.0,<1.0.0
astroML>=0.2,<1.0
scikit-learn>=0.14.1,<1.0.0
rpy2>=2.4.3,<3.0.0
这两个命令:
$ pip install --download=/tmp -r requirements.txt
$ pip install --user --no-index --find-links=/tmp -r requirements.txt
(第一个下载包,第二个安装)。
进程频繁停止并出现错误:
Could not find a version that satisfies the requirement <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2)) (from versions: )
No matching distribution found for <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2))
我手动修复的是:
pip install --user <package>
然后 运行 再次执行第二个 pip install
命令。
但这只适用于那个特定的包。当我再次 运行 第二个 pip install
命令时,该过程现在停止抱怨 另一个 需要的包,我需要再次重复该过程,即:安装手动新建所需包(使用上面的命令),然后 运行 第二个 pip install
命令。
到目前为止,我不得不手动安装 six
、pytz
、nose
,现在它抱怨需要 mock
。
有没有办法告诉 pip
自动安装 所有 需要的依赖项,这样我就不必一个一个地手动安装?
Add:这只发生在 Ubuntu 12.04 顺便说一句。在 Ubuntu 14.04 中,应用于 requirements.txt
文件的 pip install
命令没有问题。
这种方法(将所有依赖项都放在目录中而不是从索引中下载)仅在目录包含所有包时才有效。因此,该目录应包含所有依赖项以及这些依赖项所依赖的所有包(例如,six
、pytz
等)。
因此您应该手动将它们包含在 requirements.txt
中(以便第一步明确下载它们)或者您应该使用 PyPI 安装所有包然后 pip freeze > requirements.txt
来存储所有需要的包的列表.
尝试使用以下命令通过 powershell 安装 flask。
pip install --isolated Flask
这将允许安装避免环境变量和用户配置。
经过2个小时的搜索,我找到了一种只需一行命令即可修复它的方法。您需要知道软件包的版本(只需搜索 PACKAGE 版本)。
命令:
python3 -m pip install --pre --upgrade PACKAGE==VERSION.VERSION.VERSION
并非总是如此,但在某些情况下,包已经存在。例如-getpass。它未被 "pip list" 列出,但可以导入和使用:
如果我尝试 pip install getpass 我会收到以下错误: "Could not find a version that satisfies the requirement getpass"
我已经安装了 python3 但我在 /usr/bin/python 中的 python 仍然是旧的 2.7 版本
这有效(<pkg>
在我的例子中是 pyserial
):
python3 -m pip install <pkg>
使用命令提示符,然后 select 运行 作为管理员。
升级pip版本
要升级 PIP,请键入此命令,然后按 Enter:
python.exe -m pip install --upgrade pip
返回 python 路径 C:\Users\Jack\AppData\Local\Programs\Python\Python37\Scripts
输入 jupyter notebook
您将被重定向到 http://localhost:8888/undefined/tree
Jupyter 主页
希望对您有所帮助!!!!!!!!!!!!
以下命令对我有用 -
python -m pip install flask
我在 anaconda (python 3.7) 的 Windows 10 上安装 awscli
时出现此错误。
在排查问题的同时,我去了答案PyOpenSSL
、cryptography
、enum34
、idna
和 ipaddress
。安装这些后(仅使用 pip install
命令),我能够安装 awscli
.
如果您在工作场所遇到这个问题。这可能是适合您的解决方案。
pip install -U <package_name> --user --proxy=<your proxy>
虽然它并没有真正回答这个具体问题。其他人也因为这个错误得到了同样的错误信息。
对于那些像我这样的人最初忘记了-r
:使用pip install -r requirements.txt
-r
是必不可少的命令。
原答案:
只是提醒google这个错误的人过来。
假设我收到此错误:
$ python3 example.py
Traceback (most recent call last):
File "example.py", line 7, in <module>
import aalib
ModuleNotFoundError: No module named 'aalib'
既然提到了aalib
,我就想试试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
但实际上错误的包名,确保pip search
(service disabled at the time of writing), or google, or search on pypi site得到准确的包名 :
然后安装成功:
$ python3.8 -m pip install python-aalib
Collecting python-aalib
Downloading python-aalib-0.3.2.tar.gz (14 kB)
...
如pip --help
所述:
$ python3.8 -m pip --help
...
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
要有系统的方法找出根本原因而不是靠运气,您可以在 pip
命令后附加 -vvv
选项以查看详细信息,例如:
$ 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
从上面的日志中,很明显 URL https://pypi.org/simple/aalib/
404 未找到。那么你就可以猜出导致404的可能原因,即错误的包名。另一件事是我可以修改 pip 模块的相关 python 文件以进一步调试上述日志。要编辑 .whl
文件,您可以
在 MacO 上,在略有不同的情况下出现相同的错误。显然 setuptools 版本超过 45 可以暴露一些问题,这个命令让我过去了:
pip3 install setuptools==45
从 pypi.org.
安装 Pippip install -U -i https://pypi.org/simple package
一个可能的错误,pip 包需要 python 你没有使用的解释器。
我 运行 遇到同样的问题,只有当我从我的 Docker 图像(或 Docker 文件)发出 运行 命令时才会发生。终于在几个小时后,我通过更新 python 解释器设法解决了这个问题。指出我的 pip-package 需要 python>=3,7 但我的 Docker 图像使用的是 python 3.6.
提示:要检查您是否有类似问题,只需检查 pip 包要求和您的 python 版本。私有 pip 包解释器要求写在 setup.py 或 setup.cfg 中。 Public pip 包通常托管在 pypi.org 中,您可以在其中使用浏览器检查解释器要求。要检查您的 python 解释器版本,只需在您的控制台中编写例如 python --version 或 python3 --version
一般问题描述
正如其他答案指出的那样,您可能还有其他不满足的要求,这就是为什么 pip 找不到适合您的软件包版本的原因。所有要求都写在 pip 包文档中,可以从 https://pypi.org/project/graphene-django/your-package
轻松阅读如果您发现该软件包的其他版本可用,请在 google 中搜索 例如使用那个 我在使用 glob 时遇到错误,所以我改用 glob2
当我失去互联网连接时,出现了这个错误。
如果包是本地的,不要遗漏相对路径。 例如
pip install ./<pkg>
终于在我的案例中起作用了,而
pip install <pkg>
产量:
ERROR: Could not find a version that satisfies the requirement <pkg> (from versions: none)
ERROR: No matching distribution found for <pkg>
由于这是一个很烦人的问题,可能会长期困扰初学者,所以我在这里写一个完整的公会。
if you are running
pip install PACKAGE
orpython -m pip install PACKAGE
, and ano matching version found
error reported, here's how to solve the problem.
在浏览器上搜索你的包,比如我的包是
pycypto
,我这里搜索pycypto pypi
找到你的包,打开pypi上的link,点击下载文件
打开一个pythonshell,导入你安装的任意一个包,比如我之前安装过Pillow
>>> import PIL
>>> PIL.__path__
['/Applications/MAMP/htdocs/canvas/src/zzd/env/lib/python3.7/site-packages/PIL']
PACKAGE.__path__
函数将为您提供 side packages
所有包都应进入的路径。
加上:
如果您不知道之前安装了哪些软件包,运行 pip list
获取已安装软件包的列表。
- 获取路径后,打开一个shell,cd到路径
cd /Applications/MAMP/htdocs/canvas/src/zzd/env/lib/python3.7/site-packages/
open
解压下载的文件,拖入
site-packages
.cd 进入下载目录,运行
setup.py
安装
cd pycrypto-2.6.1
python setup.py install
那么你应该可以导入并使用python中的包了。