[英]Why can I use NumPy with Python 3.8 which was preinstalled but not with Python 3.9 which I installed in addition?
I installed Ubuntu 20.04, and python3 (3.8) is installed by default.我安装的是Ubuntu 20.04,默认安装的是python3(3.8)。 To install python3.9, I executed:
为了安装 python3.9,我执行了:
sudo apt install python3.9
Thus, I have two versions of Python at my laptop: 3.8 and 3.9.因此,我的笔记本电脑上有两个版本的 Python:3.8 和 3.9。
I'm trying to launch the simple script:我正在尝试启动简单的脚本:
import numpy
With Python 3.8 it works correctly.使用 Python 3.8 它可以正常工作。 But, when I interp my script by Python 3.9 the error occurs:
但是,当我通过 Python 3.9 插入我的脚本时,会发生错误:
How to solve this problem?如何解决这个问题呢?
I've already tried to update numpy using pip, nothing has happened.我已经尝试使用 pip 更新 numpy,但没有任何反应。
pip3 install numpy --upgrade
Likely what is happening here is, because you have 2 versions of python installed, your pip3
command is only installing things for one of the versions, 3.8 in this case.可能这里发生的事情是,因为你安装了 python 的 2 个版本,你的
pip3
命令只为其中一个版本安装东西,在本例中为 3.8。
Specifying the python version you want to run your command with will help solve this issue.指定要用于运行命令的 python 版本将有助于解决此问题。
For example,例如,
python3.9 -m pip install numpy
or或者
python3.8 -m pip install numpy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.