我们使用的是内部托管的PyPI服务器(devpi-server
),因此我们可以托管大型软件包的二进制文件,这些二进制文件需要很长时间才能从scipy,matplotlib等源代码安装pip install scipy
。创建。但是,如果使用我们内部开发的任何依赖于这些软件包之一的python软件包,并运行会python setup.py install|develop|test|whatever
导致以下错误:
No local packages or download links found for scipy
Traceback (most recent call last):
File "setup.py", line 136, in <module>
'develop': DevelopCommand
File "/usr/local/lib/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/users/me/virtualenvs/devpi-test/lib/python2.7/site-packages/setuptools/dist.py", line 239, in __init__
self.fetch_build_eggs(attrs.pop('setup_requires'))
File "/users/me/virtualenvs/devpi-test/lib/python2.7/site-packages/setuptools/dist.py", line 263, in fetch_build_eggs
parse_requirements(requires), installer=self.fetch_build_egg
File "/users/me/virtualenvs/devpi-test/lib/python2.7/site-packages/pkg_resources.py", line 564, in resolve
dist = best[req.key] = env.best_match(req, self, installer)
File "/users/me/virtualenvs/devpi-test/lib/python2.7/site-packages/pkg_resources.py", line 802, in best_match
return self.obtain(req, installer) # try and download/install
File "/users/me/virtualenvs/devpi-test/lib/python2.7/site-packages/pkg_resources.py", line 814, in obtain
return installer(requirement)
File "/users/me/virtualenvs/devpi-test/lib/python2.7/site-packages/setuptools/dist.py", line 313, in fetch_build_egg
return cmd.easy_install(req)
File "/users/me/virtualenvs/devpi-test/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 587, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('scipy')
和easy_install
:
$ easy_install scipy
Searching for scipy
Reading http://pypi.internal.example.com/us/base/+simple/scipy/
No local packages or download links found for scipy
error: Could not find suitable distribution for Requirement.parse('scipy')
如果我获取该网址,那么我将得到:
$ curl http://pypi.internal.example.com/us/base/+simple/scipy/
<html>
<head>
<title>us/base: links for scipy</title></head>
<body>
<h1>us/base: links for scipy</h1>
<form action="http://pypi.internal.example.com/us/base/+simple/scipy/refresh" method="post"><input name="refresh" type="submit" value="Refresh PyPI links"/></form>
us/external <a href="../../../external/+f/c48/5006bc28a8607/scipy-0.14.0-cp27-none-linux_x86_64.whl#md5=c485006bc28a8607b2fc1331df452dc1">scipy-0.14.0-cp27-none-linux_x86_64.whl</a><br/>
</body></html>
如果我请求输出中列出的URL,我会很高兴:
$ curl --silent 'http://pypi.internal.example.com/us/external/+f/c48/5006bc28a8607/scipy-0.14.0-cp27-none-linux_x86_64.whl#md5=c485006bc28a8607b2fc1331df452dc1' \
| file -
/dev/stdin: Zip archive data, at least v2.0 to extract
首先,问题中描述的问题不依赖于使用,devpi
并且可以与任何PyPI服务器一起复制,包括pypi.org上的主仓库。例:
# setup.py
from setuptools import setup
setup(name='spam', install_requires=['vprof>0.37'])
(而不是vprof
,您可以选择轮子以外的其他任何不包装的包裹)
测试一下:
$ pip install --upgrade "setuptools<38.2.0"
...
Successfully installed setuptools-38.1.0
$ python setup.py install
running install
running bdist_egg
running egg_info
writing spam.egg-info/PKG-INFO
...
Processing dependencies for spam==0.0.0
Searching for vprof>0.37
Reading https://pypi.python.org/simple/vprof/
No local packages or working download links found for vprof>0.37
error: Could not find suitable distribution for
Requirement.parse('vprof>0.37')
砰。当您将仅二进制包声明为构建依赖项时,情况会变得更糟:
setup(name='spam', setup_requires=['vprof>0.37'])
现在,所有构建和打包命令也将失败,无法下载构建部门。
该问题仅取决于所使用的setuptools
版本。从2017年11月26日开始,版本38.2.0setuptools
支持提取和安装wheel依赖项,因此如果仍然遇到此问题:
setuptools
较新的OS版本应该已经发布了的最新版本setuptools
。例如,Ubuntu 18.04setuptools==39.0.1
默认具有(link)。如果仍然安装了旧setuptools
版本,则大多数情况下将由系统软件包管理器进行管理,因此不应通过进行更新pip
。您可以用户安装的其他副本setuptools
$ pip install --user --upgrade "setuptools>=38.2.0"
或为此使用虚拟环境。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句