【发布时间】:2021-03-24 10:21:35
【问题描述】:
我正在尝试使用 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 中引入。在我看来,pip 正在安装与我的 Python 版本不兼容的软件包,特别是因为 pip 显然没有安装在安装的 Python 版本之前发布的软件包版本,这对我来说似乎很奇怪。 有没有一种简单的方法来只安装适用于我的 Python 版本的软件包版本?
【问题讨论】:
-
你能试试
python3 -m pip install numpy吗? -
好主意,但仍然报同样的错误。
-
你可以试试
sudo python3 -m pip install --upgrade pip和sudo python3 -m pip install numpy -
成功了!自动安装旧的 numpy 版本。
标签: python python-3.x numpy pip