Python在安装了numpy包之后运行出现找不到指定模块!!!


Traceback (most recent call last):
  File "D:\PyCharm2020\PythonStudent\venv\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
    from . import multiarray
  File "D:\PyCharm2020\PythonStudent\venv\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
    from . import overrides
  File "D:\PyCharm2020\PythonStudent\venv\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的程序。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\PyCharm2020\PythonStudent\test_2\first.py", line 1, in <module>
    import numpy as np
  File "D:\PyCharm2020\PythonStudent\venv\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import core
  File "D:\PyCharm2020\PythonStudent\venv\lib\site-packages\numpy\core\__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "D:\PyCharm2020\PythonStudent\venv\Scripts\python.exe"
  * The NumPy version is: "1.19.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: 找不到指定的程序。

以上是错误报告,我python是3.9的版本,安装的numpy是如下,其中pillow包运行也是错误.请大神解答!!!

有3种方法解决:

一、numpy版本换成1.19.3;

二、python版本换成3.8.6;

三、在linux操作系统下可以使用最新的3.9.1版python和1.19.4版numpy。

两个原因:

第一个就是numpy本身的问题,可以卸载重装

如果还是不行,那就是版本不对,看网上有用1.19.3解决的,可以试一下

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn numpy==1.19.3

我之前的问题就是numpy C-extensons无法处理,后面我直接添加了一个python3.7解释器,我一开始是在自己建立的python37虚拟环境中下载的numpy,然后import numpy不报错,就是一直提示DDL:找不到模块,往上翻就是C-extensions无法处理。
然后,我重新直接使用了python3.7作为编辑器

img

就是自己添加了一个,conda下的pycharm自动给我配置了之前在python虚拟环境的包,结果就ok了,不再有错误。
因为之前我看到很多人都说,下载numpy版本然后卸载安装什么的,但不直接在代码里标记红线应该就不是版本的问题,我见过的版本问题都会直接告诉你版本有问题,就是有很明显的提示。
所以我觉得是conda下的虚拟环境无法连接到你的这些包,然后我用上述方法,直接在pycharm里面重新创建一个纯python3.7的环境,就莫名其妙的成功了。
哈哈哈哈!

pip list看一下,有没有安装的模块,如果用的是ide,你需要查看下项目指定的运行环境对是否正确

信息中提示有文档

进行故障排除

https://numpy.org/devdocs/user/troubleshooting-importerror.html

 

我想问一下,我安装是不是要安装在python里面,在pycharm里面安装,是不是有问题?

 

不是在哪里装的问题,你现在首先还是得排除是不是环境设置的问题,如果不是环境的问题,再去考虑其他,比如版本啊什么的问题,一般情况下插件没有问题

windows为例:

这是pycharm的终端

这是系统终端:

你看下你的项目是在哪个虚拟环境。比如我这个pycharm是在task_nlp中,而系统终端不在。这就导致你的包可能装的位置有问题。