Cannot run numpy in pycharm

Answered

I have installed anaconda on my computer, and installed numpy package as I tried 'conda install numpy' or 'pip install numpy' 

But when I try 'import numpy as np', I still get an error like below:    can anyone help me with it? Thank you so much!!!

6 comments
Comment actions Permalink

Sure you are running the right python interpreter / installed it for the right python?   Why not use pycharm's Preferences/Project/Project Interpreter to install numpy and select python version?

0
Comment actions Permalink

same issue w/ 2018.2.4, python 3.7.0, numpy 1.15.2 on windows 7; 

0
Comment actions Permalink

Please attach a screenshot showing the problem and a screenshot with your Project Interpreter window (Settings/Preferences | Project | Project Interpreter).

0
Comment actions Permalink

Similar issue here. 2018.2.4, python 3.7.0, numpy 1.15.3 on windows 7.

numpy test works in Anaconda prompt.

I see numpy installed in the list of Project interpreter packages. But running "import numpy as np" in PyCharm gives:

Traceback (most recent call last):
File "C:\Users\lvn\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
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 "C:\Users\lvn\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-11-0aa0b027fcb6>", line 1, in <module>
import numpy as np
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\lvn\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\lvn\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\lvn\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\lvn\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\lvn\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
Comment actions Permalink

For those who are new to pycharm (like myself) without experience on setting up interpreter/env, you have to set the interpreter as system interpreter to access to the system modules that come with anaconda(python in PATH). Otherwise, if you set the interpreter as any of the other 3 interpreter options including the first option(conda), pycharm will create project specific site-packages folder and project specific env.

0

Please sign in to leave a comment.