【问题标题】:Install fails with requirements.txt but works with pip install安装失败并出现 requirements.txt 但适用于 pip install
【发布时间】:2017-05-07 08:13:30
【问题描述】:

在使用 requirements.txt 与直接使用 pip 安装时,我看到了一些奇怪的行为。希望您能对此有所了解。

这可能与这个未回答的问题相同:pip install -r requirements.txt fails on scipy, but works when run manually line-by-line

Python 2.7.6

Django 1.6.11

当我像这样使用 requirements.txt 安装 mailchimp3 时:

sudo /usr/local/python/django/bin/pip install -r config/myvr/requirements.txt

安装失败,我看到了:

Collecting mailchimp3==2.0.3 (from -r config/myvr/requirements.txt (line 73)) 2016-12-21 11:23:22,286 [salt.loaded.int.module.cmdmod][ERROR ][1759] stderr: /usr/local/python/django/local/lib/python2.7/site-packages/pip/req/req_f ile.py:129: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options. cmdoptions.check_install_build_global(options, opts) /usr/local/python/django/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLCon text object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more informati on, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Could not find a version that satisfies the requirement mailchimp3==2.0.3 (from -r config/myvr/requirements.txt (line 73)) (from versions: ) No matching distribution found for mailchimp3==2.0.3 (from -r config/myvr/requirements.txt (line 73)) 2016-12-21 11:23:22,286 [salt.loaded.int.module.cmdmod][ERROR ][1759] retcode: 1

但是,当我像这样直接安装时: sudo /usr/local/python/django/bin/pip install mailchimp3==2.0.3

安装成功:

(django)ubuntu@dev:~/myvr$ sudo /usr/local/python/django/bin/pip install mailchimp3==2.0.3 The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting mailchimp3==2.0.3 /usr/local/python/django/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning. SNIMissingWarning /usr/local/python/django/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Downloading mailchimp3-2.0.3-py2.py3-none-any.whl (83kB) 100% |████████████████████████████████| 92kB 413kB/s Requirement already satisfied: requests in /usr/local/python/django/lib/python2.7/site-packages (from mailchimp3==2.0.3) Installing collected packages: mailchimp3 Successfully installed mailchimp3-2.0.3 (django)ubuntu@dev:~/myvr$

这必须使用需求文件安装,而不是直接为我们的生产环境安装。你有没有可能知道这里有什么?

您还需要其他信息吗?

【问题讨论】:

  • 您可以发布您的 requirements.txt 文件以及您使用的 pip 版本吗?

标签: python django python-2.7 pip requirements.txt


【解决方案1】:

问题是在 requirements.txt 文件中存在对 lxml 的依赖项,并且该依赖项设置为在没有线程的情况下安装,所以它看起来像这样

lxml==3.5.0 --install-option='--without-threading'

任何时候通过--install-option(或--build-options--global-options),都会禁用所有轮子。

对于mailchimp3,它需要轮子才能正确安装。

我们的解决方案是将lxml 的安装移到单独的构建步骤中。

【讨论】:

    【解决方案2】:

    无法查看您的错误消息,但您可以检查您的 requirements.txt 是否包含依赖于同一文件中列出的包的包。假设 req 文件包含 pack1 和 pack2,如果稍后调用 pack1 import pack2 和 pack2,则安装将失败。我有问题,这里有一个类似的problem on github

    【讨论】:

      猜你喜欢
      • 2022-01-23
      • 2019-08-27
      • 2013-10-08
      • 1970-01-01
      • 2019-10-31
      • 2018-03-24
      • 1970-01-01
      • 2012-10-15
      • 2021-02-16
      相关资源
      最近更新 更多