我的电脑里有 python3.5 和 python3.6。当我尝试在 numpy3.6 中导入 python 时,出现错误。当我尝试通过 安装 numpy 时sudo pip3 install numpy
,出现消息Requirement already satisfied: numpy in /home/user/.local/lib/python3.5/site-packages
。如何为 python 3.6 安装 numpy?
这是我导入 numpy 时遇到的异常:
Python 3.6.3 (default, Oct 6 2017, 08:44:35) [GCC 6.3.0 20170406] on linux Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'numpy' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg ModuleNotFoundError: No module named 'apt_pkg'
Original exception was: Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'numpy'
>>>
谢谢
答案1
确保pip
已安装:
wget https://bootstrap.pypa.io/get-pip.py
和:
sudo python3.6 get-pip.py
然后你可以numpy
使用以下命令进行安装:
sudo python3.6 -m pip install numpy