为什么 pip 会尝试在 python2 virtualenv 中安装不兼容版本的库?
Why does pip try to install an incompatible version of a library in a python2 virtualenv?
以图书馆more-itertools
为例。它已指定 python_requires = >= 3.4
以指示它与以前的版本不兼容。
当我尝试在全新的 virtualenv (pip==19.2.3, setuptools==41.2.0) 中 pip install more-itertools
时,出现以下错误:
ERROR: Package 'more-itertools' requires a different Python: 2.7.10 not in '>=3.4'
我的问题是:如何让 pip 安装兼容的先前版本?这可能吗,还是我必须将我的依赖项固定到以前的版本?
我在 pip install --help
中没有看到任何在这里特别有用的内容。
好吧,我现在更糊涂了。
在新 docker 上尝试一下,它似乎开箱即用:
from centos:centos7
RUN yum install -y epel-release
RUN yum install -y python-pip
RUN python -m pip install -U virtualenv pip
RUN mkdir /test
WORKDIR /test
RUN virtualenv venv
ENV PATH="/test/venv/bin:$PATH"
RUN pip install more-itertools
此安装 more-itertools==5.0.0
编辑:事实证明这是我使用的索引服务器的问题,它在安装时无法正确传达 python_requires 元数据。
以图书馆more-itertools
为例。它已指定 python_requires = >= 3.4
以指示它与以前的版本不兼容。
当我尝试在全新的 virtualenv (pip==19.2.3, setuptools==41.2.0) 中 pip install more-itertools
时,出现以下错误:
ERROR: Package 'more-itertools' requires a different Python: 2.7.10 not in '>=3.4'
我的问题是:如何让 pip 安装兼容的先前版本?这可能吗,还是我必须将我的依赖项固定到以前的版本?
我在 pip install --help
中没有看到任何在这里特别有用的内容。
好吧,我现在更糊涂了。
在新 docker 上尝试一下,它似乎开箱即用:
from centos:centos7
RUN yum install -y epel-release
RUN yum install -y python-pip
RUN python -m pip install -U virtualenv pip
RUN mkdir /test
WORKDIR /test
RUN virtualenv venv
ENV PATH="/test/venv/bin:$PATH"
RUN pip install more-itertools
此安装 more-itertools==5.0.0
编辑:事实证明这是我使用的索引服务器的问题,它在安装时无法正确传达 python_requires 元数据。