微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ModuleNotFoundError:在python 3.9中没有名为“scipy”的模块

如何解决ModuleNotFoundError:在python 3.9中没有名为“scipy”的模块

我在 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 integratepython3.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

解决方法

也许试试

python3.9 -m pip install scipy --user

使用python3.9的pip安装包到没有sudo权限的地方

,

使用pipwin

pip install pipwin

下载后

pipwin install scipy
,

试试 pip3 install scipy, 如果返回 ERRNO 13: access denied 然后尝试 pip3 install scipy --user

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。