Problem
假设我在 Linux 机器上有一个完全空的 Python+Pip+R (pip 19.3.1) 环境,并且我想安装该包rpy2
与点。由于我位于公司防火墙后面,因此我将 pip 配置为使用私有存储库。
[global]
index-url = http://private.com/artifactory/api/pypi/PyPI/simple
trusted-host = private.com
现在我执行pip install rpy2
我会得到以下错误:
Couldn't find index page for 'cffi'
Download error on https://pypi.python.org/simple/
因此 pip 尝试通过查找和安装来解决嵌套依赖关系cffi
来自官方 PyPi 存储库。它完全忽略我配置的存储库。
当我跑步时pip install cffi && pip install rpy2
一切都按预期进行。
这是完整的错误输出:
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8vuadu93/rpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8vuadu93/rpy2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-8vuadu93/rpy2/pip-egg-info
cwd: /tmp/pip-install-8vuadu93/rpy2/
Complete output (25 lines):
Download error on https://pypi.python.org/simple/cffi/: [Errno -2] Name or service not known -- Some packages may not be found!
Couldn't find index page for 'cffi' (maybe misspelled?)
Download error on https://pypi.python.org/simple/: [Errno -2] Name or service not known -- Some packages may not be found!
No local packages or working download links found for cffi>=1.13.1
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-8vuadu93/rpy2/setup.py", line 183, in <module>
'rinterface_lib/R_API_eventloop.h']}
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 128, in setup
_install_setup_requires(attrs)
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 123, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 513, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 774, in resolve
replace_conflicting=replace_conflicting
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1057, in best_match
return self.obtain(req, installer)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1069, in obtain
return installer(requirement)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 580, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 692, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('cffi>=1.13.1')
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Question
这是 Pip 中的错误,rpy2 的特定问题还是我遗漏了什么?
Updates
运行以下命令给我同样的错误:
pip install rpy2 --no-index --find-links http://private.com/artifactory/api/pypi/PyPI/simple
pip install rpy2 --index-url http://private.com/artifactory/api/pypi/PyPI/simple
I used -vvv
问题似乎发生在内部某个地方setuptools
Solution
套餐rpy2
uses setuptools
再次使用easy_install.py
。它也适用于index_url
多变的。但它的价值不是来自pip.config
but distutils.cfg
.
我识别了我安装的所有 Python 版本find / -name "distutils"
。然后我添加了一个distutils.cfg
每个目录中包含以下内容:
[easy_install]
index_url = blablabla
现在它起作用了,我执行pip install rpy2
并且所有缺少的要求都一次性安装