我在Requirements.txt文件的–global-option和–install- option设置上遇到困难。为一个库指定选项会导致其他库安装失败。
我正在尝试安装Python库“ grab”和“ pycurl”。我需要指定pycurl安装选项:“-with- nss”。我可以在完全干净的虚拟环境中复制错误。
在新的虚拟环境中,带有requirements.txt的文件包含:
grab==0.6.25 pycurl==7.43.0 --install-option='--with-nss'
然后安装:
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安装也会失败。
无论如何,是否只能将安装选项传递给一个库?
我是在Amazon Elastic Beanstalk实例上进行设置的,因此没有选项可以手动运行requirements.txt文件的每一行- 整个安装将在应用程序启动时运行。
--global-option和–install-option的来源(我认为不应这样做): 如何在pip冻结产生的需求文件中维护pip安装选项? https://github.com/pypa/pip/blob/develop/docs/reference/pip_install.rst#id28
您的问题来自这样一个事实,即带有EB的EC2上的PIP版本已经很旧,并且无法理解您的选择。
project_dir / .ebextensions / 02-python.config:
... commands: 01_upgrade_pip_for_venv: command: "/opt/python/run/venv/bin/pip install --upgrade pip" ...
project_dir / requirements.txt:
... pycurl==7.43.0 --global-option="--with-nss" ...
eb setenv PYCURL_SSL_LIBRARY = nss