【问题标题】:pip install .[test] not working in python2.7.9 pip version 6.0.7pip install .[test] 在 python2.7.9 pip 版本 6.0.7 中不起作用
【发布时间】:2017-02-28 13:27:30
【问题描述】:

据我所知 pip install .[extras_require here] 一直有效。添加该功能时,我在任何文档中都找不到,但即使在非常旧的机器上我也从未遇到任何问题。

pip 绝对是这里的问题。我可以添加“pip install --upgrade pip”,但我没有对当前存在问题的存储库的合并权限。

来自 setup.py

extras_require={
    'test': ['flake8', 'pytest>=2.9.0'],
},

在 python 2.7.9 中

$ python --version
Python 2.7.9
$ pip --version
pip 6.0.7 from /home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages (python 2.7)
$ pip install .[test]
Collecting .[test]
  Could not find any downloads that satisfy the requirement .[test]
  No distributions at all found for .[test]


The command "pip install .[test]" failed and exited with 1 during .

从 3.5.2 开始:

$ python --version
Python 3.5.2
$ pip --version
pip 9.0.1 from /home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages (python 3.5)
$ pip install .[test]
Processing /home/travis/build/Brian-Williams/repo_python
Collecting flake8 (from refactor-me==0.1.0)
  Downloading flake8-3.3.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 6.1MB/s 
Requirement already satisfied: pytest>=2.9.0 in /home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages (from refactor-me==0.1.0)
Collecting pycodestyle<2.4.0,>=2.0.0 (from flake8->refactor-me==0.1.0)
  Downloading pycodestyle-2.3.1-py2.py3-none-any.whl (45kB)
    100% |███████████████���████████████████| 51kB 10.6MB/s 
Collecting mccabe<0.7.0,>=0.6.0 (from flake8->refactor-me==0.1.0)
  Downloading mccabe-0.6.1-py2.py3-none-any.whl
Collecting pyflakes<1.6.0,>=1.5.0 (from flake8->refactor-me==0.1.0)
  Downloading pyflakes-1.5.0-py2.py3-none-any.whl (225kB)
    100% |████████████████████████████████| 225kB 7.1MB/s 
Requirement already satisfied: py>=1.4.29 in /home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages (from pytest>=2.9.0->refactor-me==0.1.0)
Installing collected packages: pycodestyle, mccabe, pyflakes, flake8, refactor-me
  Running setup.py install for refactor-me ... - done
Successfully installed flake8-3.3.0 mccabe-0.6.1 pycodestyle-2.3.1 pyflakes-1.5.0 refactor-me-0.1.0

【问题讨论】:

  • 看起来这一点在 pip 的 1.1 版本中已得到支持。见here

标签: python pip extras


【解决方案1】:

对于您需要运行的 pip 版本

pip install -e .[test]

be able to install extras from a directory

【讨论】:

  • 这就是我正在做的。来自 .travis.yml:'pip install ".[test]"'
  • 你没有这样做。你错过了-e
  • -e 只是在编辑器模式下安装,这是不必要的,因为这是 CI 作业的一部分,其中代码不会被编辑,一旦完成,容器将被删除。我还通过升级 pip 解决了以下问题,但仍然没有在编辑器模式下安装。在没有理由的情况下使用可变代码是个坏主意。
  • pip 6.0.7 只能在进行可编辑安装时从路径安装 extras。此外,不鼓励可编辑的安装,pytest docs even specifically mention an editable install
  • 好的,现在您已编辑答案以指定版本中需要编辑器模式。
【解决方案2】:

我获得了合并访问权限。将升级 pip 添加到 .travis.yml 的安装阶段修复它:

install:
  # update pip to ensure extras_require format is supported
  - 'pip install --upgrade pip'
  - 'pip install ".[test]"'

从成功运行将 6.0.7 替换为 pip-9.0.1 是增量。

【讨论】:

    猜你喜欢
    • 2019-11-25
    • 2017-01-31
    • 2013-10-25
    • 2016-06-30
    • 2017-02-20
    • 1970-01-01
    • 2021-03-25
    • 2021-08-13
    • 1970-01-01
    相关资源
    最近更新 更多