tra*_*nag 5 python pip artifactory rpy2 python-cffi
假设我在 Linux 计算机上有一个完全空的 Python+Pip+R (pip 19.3.1) 环境,并且我想使用rpy2pip 安装该包。由于我位于公司防火墙后面,因此我将 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/
cffi因此,pip 尝试通过从官方 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.
这是 Pip 中的错误,rpy2 的特定问题还是我遗漏了什么?
运行以下命令给我同样的错误:
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
我使用过-vvv,问题似乎发生在内部某处setuptools
该包再次rpy2使用. 它也适用于变量。但它的值不是来自but 。setuptoolseasy_install.pyindex_urlpip.configdistutils.cfg
我确定了随find / -name "distutils". 然后我将包含以下内容的 a 添加distutils.cfg到每个目录中:
[easy_install]
index_url = blablabla
现在它可以工作了,我执行pip install rpy2并一次性安装了所有缺少的要求
我相信这可能是由rpy2中cffi列出的事实引起的。很可能是因为在安装之前需要先构建项目本身。这种构建依赖项不是由pip直接处理的,因此它的选项不起作用。setup_requiressetup.pycffiindex-url
解决方案是告诉setuptools distutils配置文件中的替代索引
[easy_install]
index_url = https://my.index-mirror.com
参考: