【发布时间】:2021-05-06 22:52:25
【问题描述】:
我在 ubuntu 18.04 上运行 python3.9。我已经继续运行命令sudo apt-get install python-scipy 并收到消息:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-scipy is already the newest version (0.19.1-2ubuntu1).
The following packages were automatically installed and are no longer required:
linux-hwe-5.4-headers-5.4.0-42 linux-hwe-5.4-headers-5.4.0-53
linux-hwe-5.4-headers-5.4.0-56 linux-hwe-5.4-headers-5.4.0-58
linux-hwe-5.4-headers-5.4.0-59 linux-hwe-5.4-headers-5.4.0-60
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
然而,当我尝试运行使用 from scipy import integrate 的 python3.9 代码时,我得到了错误:
ModuleNotFoundError: No module named 'scipy'
我已经阅读了这个 post 并尝试使用卸载和安装 scipy
sudo apt-get install python3-scipy
但这不起作用。有什么建议吗?
编辑 1:我尝试了sudo pip3 install scipy,它产生了消息:
The directory '/home/nick/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/nick/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
然而,当我再次尝试运行代码时,我仍然得到相同的ImportError。
【问题讨论】:
-
尝试在pip3前加-H
-
Requirement already satisfied: scipy in /usr/lib/python3/dist-packages -
运行以下命令:
pip freeze | grep scipy。它返回什么?