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

Completed

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!

31 comments

Hi Adam,

Thank you for contacting PyCharm support.

Have you tried to reinstall numpy? Does the problem remain? 

Kind regards,

Sergey

 

0

Hi Sergey,

Reinstalling of numpy/miniconda/PyCharm didn't solve it, but adding miniconda to the path fixed it.

This seems weird though, because I've got a couple of other systems that work fine with the exact same conda environments without adding miniconda to the path.

Thanks,

Adam

0

Hi Sergey,

Reinstalling of numpy/miniconda/PyCharm didn't solve it, but adding miniconda to the path fixed it.

This seems weird though, because I've got a couple of other systems that work fine with the exact same conda environments without adding miniconda to the path.

Thanks,

Adam

0

Thanks for letting me know!

Feel free to contact us if you ever have any questions or problems.

0

I also encountered this issue on windows 10. I just downgraded to python 3.6 and numpy 1.12 to resolve the problem as it is preferable to the solution mentioned above of adding miniconda to the path. Note that I was able to use python 3.7 with numpy 1.15 in an anaconda console just fine. It was just scripts run from within pycharm that could not import numpy.

0

I am having the same problem. Just installed pycharm 2018.2.4(professional edition) on Windows 10 with Anaconda3. I tried adding anaconda to my path but that did not fix the problem for me.

Is there something else I can try or is there an update on this issue?

 

Thanks.

0

Hi Jharbaughx42,

There is a related issue in our issue tracker https://youtrack.jetbrains.com/issue/PY-27234, please vote for it and follow for updates.

0

After looking to these resources:

https://youtrack.jetbrains.com/issue/PY-27234

https://github.com/numpy/numpy/issues/12395

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001224859-Pycharm-fails-to-import-numpy-and-snappy-using-anaconda-environment

I see that mainly the problem is related to the required Anaconda3\Library\bin or C:\Anaconda3\env\ENVNAME\Library\bin

is there a workaround that doesnt relate to launch pycharm from an activated anaconda env? like generate and append the paths to the current anaconda enviroment at the moment of start the python console?

1

Hi A00799342,

A workaround could be:

- run print(os.environ['PATH']) in the system terminal using the same interpreter

- copy the result and add them as PATH environment variable to your Run/Debug Configuration

- do the same for Python Console settings to get it working too.

0

the problem has not been solved 

I use 

Anaconda3-2018.12-Windows-x86_64 and 

pycharm-professional-2018.3.2

and got this:

"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']

May I ask you that how to solve this issue? Thank you very much

0

Hi Lithium,

Does it happen when you run your script? Please attach a screenshot showing the problem or the whole console output.

Edit: I can see your another report https://intellij-support.jetbrains.com/hc/en-us/community/posts/360002481520
Let's move there.

0

I found a solution thanks to user A00799342 comment.  

My original error was as posted above:
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.

Note: I only encountered this error in PyCharm.  I was able to successfully run the same code with numpy using Anaconda command prompt.

Solution: I added Anaconda3/Library/Bin to environment path and PyCharm no longer complained with the error.  

Hope this helps someone.

1

I have the same problem, python script containing only "import numpy as np" fails with this error when executed from PyCharm :

C:\Users\Marc\Anaconda3\python.exe C:/Users/Marc/PycharmProjects/numpy_import_bug/numpy_import_bug.py
Traceback (most recent call last):
File "C:\Users\Marc\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: Le module spécifié est introuvable.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Marc/PycharmProjects/numpy_import_bug/numpy_import_bug.py", line 1, in <module>
import numpy as np
File "C:\Users\Marc\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\Marc\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Marc\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\Marc\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Marc\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: Le module spécifié est introuvable.


Process finished with exit code 1

It works when executed from the Anaconda console in command line mode :

(base) C:\Users\Marc\PycharmProjects\numpy_import_bug>python numpy_import_bug.py

(base) C:\Users\Marc\PycharmProjects\numpy_import_bug>

The interpreter is the same in both cases :

(base) C:\Users\Marc\PycharmProjects\numpy_import_bug>python
Python 3.7.2 (default, Jan 2 2019, 17:07:39) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import numpy as np
>>> np.version.full_version
'1.15.4'
>>>

 

 

0

I'm having a similar issue. Funny enough though. I have an old conda Environment with python and numpy installed, which still works. Whenever I try to create a new conda Environment thouhg I get the same error.

I'm using python 3.6.8 and I tried a number of different numpy versions, which all gave the same error.

0

I don't know what happend. I have had to Downgrade to python 3.5 nothing else worked for me. Python 3.7 won't even start up the console.

0

Since PyCharm cannot solve this big issue, so my solution is that I deleted PyCharm completely, and switched to Spyder, which works very well.

0

Hi,

I am sincerely sorry for all the inconvenience.

Have you tried the EAP build I mentioned above? It should have a fix for it.

0

It seems that ; I have the same issue

i have created anaconda environment that has tensorflow library and it can run on anaconda prompt screen when i have type "import tensorflow as tf" etc.

After that i have opened pycharm with that environment as interpreter on pycharm project however i have face that issue 

How could we solve this or you may ask me more info to understand?

Traceback (most recent call last):
File "C:\Users\cetin\Anaconda3\envs\tensorK\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 "D:/First/Projects/visionApi/pycharM/untitled4/test.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\cetin\Anaconda3\envs\tensorK\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\cetin\Anaconda3\envs\tensorK\lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>
import numpy as np
File "C:\Users\cetin\Anaconda3\envs\tensorK\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\cetin\Anaconda3\envs\tensorK\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\cetin\Anaconda3\envs\tensorK\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\cetin\Anaconda3\envs\tensorK\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\cetin\Anaconda3\envs\tensorK\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

Dear Sergey Karpov ,

Due to personal issues i am late,

Thank you  so much , it is running ,

Best regards

0

Hi I encountered the same problem, and there is no longer import errors when importing numpy/scipy after using the EAP version.

However, I still get errors from the syntax checking, though it runs fine:

Hovering over the warning:

Cannot find reference 'exp' in '__init__.py' less... (Ctrl+F1)
Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.

I am using Anaconda on Windows 10, 64 bit. Numpy version is the latest available from conda, 1.15.4 (I think they removed the 1.16 versions from conda because of some issues people were having).

0

I've installed the EAP but still having trouble.

python: 3.7.1

numpy: 1.15.4

pycharm: PyCharm 2019.1 EAP (Professional Edition)
Build #PY-191.5532.45, built on February 14, 2019
PyCharm EAP User
Expiration date: March 16, 2019
JRE: 11.0.2+153 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

My script:

import numpy as np
print('hello world')
0

Hi J_,

Your problem is different. What is the name of the file?

Try File | Invalidate Caches/Restart...

0

Hi Don,

We are looking into issue, please vote for https://youtrack.jetbrains.com/issue/PY-34088 and feel free to leave a comment.

Reinstall of your anaconda/miniconda and adding it to PATH during installation (there will be corresponding checkbox for that) should solve the problem.

0

Hi Sergey,

I see, I didn't have this problem before my update of numpy that eventually led to the import error etc. Which is why I thought this two were related.

I managed to replicate this in a test folder on my desktop: C:\Users\user\Desktop\test\test.py;

just two lines: `import numpy as np; np.zeros()` and the `zeros` is highlighted as "cannot find reference".

I tried to `Invalidate Caches and Restart` and the issue persists.

Note that this only happens for `numpy` and/or `scipy`. And not for other packages like `random` or `sklearn`.

0

Please attach a screenshot of your Settings/Preferences | Project | Project Interpreter and another one with Settings/Preferences | Project | Project Structure

The problem is reproducible for me only if I have some custom package named numpy in my project.

0

Project Interpreter: (sorry it's quite long) --> This is the only interpreter I have

Project Structure:

0

Hmm, I tried it on my side with the same setup, but it works just fine.

What is your PyCharm version?

Please upload your renamed idea.log from Help | Show Log in... to https://uploads.services.jetbrains.com/ and let me know the name of the file.

0

Hi Sergey,

Thanks for investigating, I've uploaded under the file name "idea_j123.log".

Pycharm About page:

PyCharm 2019.1 EAP (Community Edition)
Build #PC-191.5532.45, built on February 15, 2019
JRE: 11.0.2+153 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

This is the EAP version that I downloaded a couple of days ago; In the meantime I'm going to try to reinstall numpy and scipy via conda and see if it helps..

EDIT: Created a new environment, activated it, conda installed numpy and still faced the same "cannot find reference" error..

ps. if this is totally unrelated to the thread here, let me know if I should open a new thread..

0

Please sign in to leave a comment.