繁体   English   中英

Pip安装包不兼容Python版本

[英]Pip installing packages incompatible to Python version

我正在尝试使用 docker 安装 numpy,但出现以下错误:

 ---> Running in 9f2546faf5d7
Collecting numpy
  Downloading https://files.pythonhosted.org/packages/c5/63/a48648ebc57711348420670bb074998f79828291f68aebfff1642be212ec/numpy-1.19.4.zip (7.3MB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-xoiwnjj7/numpy/setup.py", line 68
        f"NumPy {VERSION} may not yet support Python "
                                                     ^
    SyntaxError: invalid syntax
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-xoiwnjj7/numpy/
You are using pip version 8.1.1, however version 20.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip3 install numpy' returned a non-zero code: 1

这是 Dockerfile:

from ubuntu:16.04

run apt-get update && apt-get install -y  \
python3-pip

run pip3 install \
numpy

Python 版本是 3.5.2。 问题似乎是 f-string 语法仅在 Python 3.6 中引入。 It seems weird to me that pip is installing packages that are not compatible with my version of Python, especially since pip apparently doesn't install versions of packages that were released before the installed Python version. 是否有一种简单的方法来仅安装适用于我的 Python 版本的软件包版本?

似乎这是来自此线程的 ubuntu 16.04 特定问题。

以 root 身份升级 pip,因此如果 pip 安装在其他位置,则可以升级。

要升级 pip,请运行sudo python3 -m pip install --upgrade pip

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM