簡體   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