我有一个安装了 python 3.5.2
的虚拟环境。
如果我尝试使用假版本号安装 Pandas,例如通过执行 pip install Pandas==x
我可以看到匹配的发行版是:
Could not find a version that satisfies the requirement Pandas==x.x. (from versions: 0.1, 0.2b0, 0.2b1, 0.2, 0.3.0b0, 0.3.0b2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0rc1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0rc1, 0.8.0rc2, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0rc1, 0.19.0, 0.19.1, 0.19.2, 0.20.0rc1, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0rc1, 0.21.0, 0.21.1, 0.22.0, 0.23.0rc2, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0rc1, 0.24.0, 0.24.1, 0.24.2, 0.25.0rc0, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0rc0, 1.0.0) No matching distribution found for Pandas==x
这意味着 Pandas==1.0.0 应该可用,但是,当我尝试安装它时,出现以下错误:
Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-uc6w1vdn/pandas/setup.py", line 42 f"numpy >= {min_numpy_ver}", ^ SyntaxError: invalid syntax
因为它使用 f-string,从 python 3.6 开始可用。
为什么 pip 显示不兼容的版本?它不应该只显示我能够安装的版本吗?
最佳答案
显然,pip
显示了该包的所有可用版本,无论 Python 版本要求如何。
以下部分documentation建议:
Since version 6.0, pip also supports specifiers containing environment markers like so:
SomeProject ==5.4 ; python_version < '2.7' SomeProject; sys_platform == 'win32'
python_version
与包的版本分开指定。
运行pip时可以通过以下方式设置(默认为解释器版本):
pip install --python-version= pandas==
关于python-3.x - Pandas 1.0.0 与 python 3.5 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60077573/