Numpy import error in PyCharm (Importing the multiarray numpy extension module failed)

已完成

I've happily used PyCharm professional for a while. Following a fresh reinstall of miniconda and PyCharm, importing numpy in any conda environment leads to the following error:

ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try 'git clean -xdf' (removes all files not under version control). Otherwise reinstall numpy. Original error was: DLL load failed: The specified module could not be found.

The python interpreter is set properly (and is printed at the top of the PyCharm console). Importing numpy works just fine outside of PyCharm.

Does anyone have any insights as to why this is now happening?

Python 3.7 with numpy 1.15.2 and PyCharm professional 2018.2.4 on Windows 10.

Thanks!

1

Ok, I managed to reproduce it on Windows and I believe it is covered by https://youtrack.jetbrains.com/issue/PY-23521. Though this isn't EAP specific. Please vote for the issue and follow for future updates.

0
Avatar
Permanently deleted user

Hi,

The above issue, for me, was solved by simply making sure the Conda Environment option was selected when using the Add Local Python Interpreter dialogue. If I added the interpreter with Virtual Environment selected (default) then the issue would occur.

Dave

0
Avatar
Permanently deleted user

Hi I seem to be experiencing the same numpy problem. Do i need to download the EAP build?

Traceback (most recent call last):
File "C:\tools\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "q1_main.py", line 2, in <module>
import numpy as np
File "C:\tools\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\tools\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\tools\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\tools\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\tools\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: DLL load failed: The specified module could not be found.

0
Avatar
Permanently deleted user

I have this same problem with 2019.1 Community.

Everything works fine when launching pycharm from the anaconda prompt of the corresponding environment.

 

0
Avatar
Permanently deleted user

https://github.com/ContinuumIO/anaconda-issues/issues/1508 

@mingwandroid

Following their discussion, it seems removing all the anaconda path in Enviroment Variable can rescue this!  

 

0
Avatar
Permanently deleted user

This problem has resurfaced in PyCharm 2020.3.2. I've updated a couple of days ago to find this problem. I am using anaconda virtual environments and everything worked nicely before the update. Every time I start Pycharm, it shows the error, and to solve it I have to remove the conda environment from PyCharm every time and add it again to make it work. This fix works, but it is really annoying to do every time I close and fire up PyCharm. Is there any permanent fix for this or will I have to wait for the updated version?

PyCharm 2020.3.2 (Professional Edition)
Build #PY-203.6682.179, built on December 30, 2020
Runtime version: 11.0.9.1+11-b1145.63 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 976M
Cores: 4
Non-Bundled Plugins: com.jetbrains.intellij.datalore

0

Mohammadwaseem043

Please file an issue to https://youtrack.jetbrains.com/issues/PY and attach the environme.yml (conda env export > environment.yml should do the trick) file of your conda environment. We'll investigate.

0

Let me tell you, this problem frustratingly still persists in 2021. Until recently, importing numpy worked just fine, now (possibly after some update or so) it doesn't.

I have PyCharm 2021.2.2 and have installed the lastest versions of Anaconda3 and Miniconda and tried to point them out in the system PATH variable as well as the Run-settings in PyCharm. No difference, the dll necessary for numpy still fails to load in the aforementioned fashion.

What to do?

0

Lrm Johansson

So it seems the conda environment is not activated properly for some reason. Please submit an issue to https://youtrack.jetbrains.com with the following info:

- Screenshot of the interpreter settings

- The location of your conda base executable

- The output of the following snippet:

import os, sys

print(sys.executable)
print(os.getenv('CONDA_PREFIX'))

I would also recommend to try the latest PyCharm just in case

https://www.jetbrains.com/pycharm/download/

0

请先登录再写评论。