Pip Requirements.txt --global-option导致与其他软件包的安装错误. “选项未被识别"; [英] Pip Requirements.txt --global-option causing installation errors with other packages. "option not recognized"

查看:96
本文介绍了Pip Requirements.txt --global-option导致与其他软件包的安装错误. “选项未被识别";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用requirements.txt文件的--global-option和--install-option设置时遇到困难.为一个库指定选项会导致其他库安装失败.

I'm having difficulties with the --global-option and --install-option settings for a requirements.txt file. Specifying the options for one library is causing other libraries installs to fail.

我正在尝试安装Python库"grab"和"pycurl".我需要指定使用选项"--with-nss"安装pycurl.我可以在完全干净的虚拟环境中复制错误.

I'm trying to install Python libraries "grab" and "pycurl". I need to specify that pycurl be installed with option: "--with-nss". I can replicate the error on a completely clean virtual enviroment.

在新的虚拟环境中,其中requirements.txt包含:

On a new virtual environment With requirements.txt containing:

grab==0.6.25
pycurl==7.43.0 --install-option='--with-nss'

然后通过以下方式安装:

Then installing with:

pip install -r requirements.txt

将发生以下错误.

Installing collected packages: lxml, pycurl, pytils, six, user-agent, weblib, selection, grab
  Running setup.py install for lxml ... done
  Running setup.py install for pycurl ... done
  Running setup.py install for pytils ... error
    Complete output from command /home/ec2-user/test/env/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8GvFzA/pytils/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n
'), __file__, 'exec'))" install --record /tmp/pip-BCG3Wl-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/test/env/include/site/python2.7/pytils --with-nss:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --with-nss not recognized

    ----------------------------------------
Command "/home/ec2-user/test/env/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8GvFzA/pytils/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
install --record /tmp/pip-BCG3Wl-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/test/env/include/site/python2.7/pytils --with-nss" failed with error code 1 in /tmp/pip-build-8GvF
zA/pytils/

我对根本原因的最佳猜测是将选项"--with-nss"传递给所有需要pycurl的库,并阻止了安装.即使pycurl安装可以正常工作,pytils安装也会失败.

My best guess at the root cause is that the option "--with-nss" is being passed to all libraries that require pycurl, and preventing install. The pytils installation fails even though the pycurl install works fine.

总有办法只将安装选项传递给一个库吗?

Is there anyway to only pass the install options to the one library?

我正在Amazon Elastic Beanstalk实例上进行此设置,因此没有选项可以手动运行require.txt文件的每一行-整个安装都在应用程序启动时运行.

I'm setting this up on an Amazon Elastic Beanstalk instance, so there is no option to manually run each line of the requirements.txt file - the whole install gets run at start up of the application.

-global-option和--install-option的来源(我认为不应这样做): 如何维护pip安装选项点子冻结制成的需求文件中的内容? https://github.com/pypa/pip/blob/develop/docs/reference/pip_install.rst#id28

Sources for --global-option and --install-option (which I think shouldn't do this): How to maintain pip install options in requirements file made by pip freeze? https://github.com/pypa/pip/blob/develop/docs/reference/pip_install.rst#id28

推荐答案

您的问题来自以下事实:带有EB的EC2上的PIP版本太旧了,无法理解您的选择.

Your problem comes from the fact that PIP version on EC2 with EB is quite old and does not understand your options.

  1. 使用EB命令将pip库更新为最新可用版本:

project_dir/.ebextensions/02-python.config:

project_dir/.ebextensions/02-python.config:

...
commands:
  01_upgrade_pip_for_venv:
    command: "/opt/python/run/venv/bin/pip install --upgrade pip"
...

  1. 现在您可以在require.txt中保留选项,因为新版本的pip可以使用它.

project_dir/requirements.txt:

project_dir/requirements.txt:

...
pycurl==7.43.0 --global-option="--with-nss"
...

  1. (这可能是多余的),在EB控制台用户界面中或通过eb CLI使用以下命令设置选项:

  1. (This may be redundant) Set option in EB console user interfaces or by eb CLI with command:

eb setenv PYCURL_SSL_LIBRARY = nss

eb setenv PYCURL_SSL_LIBRARY=nss

将更改推送到存储库并重新构建.由于执行是从外部作用域控制的,并且是从旧版本的PIP开始的,因此您可能会出错.执行的入口点在EC2实例上的应用程序外部,因此我不确定如何带来在首次部署时可以在钩子范围内使用的解决方案...但是您要做的就是再次部署,并且它将使用适当的版本的PIP,因此从现在开始可以使用,直到下一次重建...

Push changes to repository and Rebuild. You may have errors since execution is controlled from external scope and started with old version of PIP. Entry point of execution is outside of app on EC2 instance so I'm not sure how to bring solution that would work from scope of hooks on first deployment... But all you have to do is to deploy again, and it will use proper version of PIP, so it will work from now on, till next rebuild...

这篇关于Pip Requirements.txt --global-option导致与其他软件包的安装错误. “选项未被识别";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆