PyCharm Won't Import Module (Numpy) Even Though It Shows It's Installed Follow
Answered
I'm sorry if this problem has already been covered. I'm new to Python and PyCharm, so I may have missed something, but I checked similar questions and didn't see a solution that applied to me.
I created a virtual environment and installed numpy using PyCharm's GUI. The screenshots below of the 1) project interpreter settings and 2) terminal verify that the installation took place.
However, when I try to import numpy in the session, I get an error:
I thought it might be something wrong with numpy itself, but the same problem occurs with pandas.
Please sign in to leave a comment.
Hi Fenixjeanne,
Thank you for contacting PyCharm support.
Please provide a screenshot of your Run/Debug Configuration window (Run | Edit Configurations...).
Looking forward to your reply.
I hope this was the screenshot you were looking for.
Please check your Python interpreter in `Settings | Build, Execution, Deployment | Console | Python Console`.
It should be the same as your Project Interpreter as shown on the screenshot with example:
Kind regards,
Sergey
https://www.jetbrains.com
The Drive to Develop
The interpreter looks to be the same - PyCharm_projs
Thanks for the update.
Is `import numpy` resolved in the Editor?
Please provide more details about the scenario. Do you import numpy in the Python Console or run code from Editor to console?
If possible, please attach a sample project so I can try to reproduce.
I imported in the console. I don't know why because I didn't change settings, but it is now working. I imported numpy just now with no problem. Could exiting the program have reset PyCharm?
That's odd.
Yes, it could be there was something with indexing. When restarted PyCharm reindexed the project and probably that is what resolved the issue.
Thank you for letting me know anyway.
Hi,
I recently installed on a fresh windows 10 installation (with all the updates) the following:
Anaconda3-2018.12-Windows-x86_64.exe
and then:
pycharm-community-2018.3.3.exe
I turned on PyCharm and created a new project with existing interpreter C:\Users\<username>\AppData\Local\Continuum\anaconda3\python.exe
I created a new python file and set the interpreter the same as the project default.
I typed "import numpy as np" and tried to run. It didn't work. Then I tried directly in the console and the same result.
The message says that it couldn't load the DLL and that it is probably broken.
A colleague tried the same thing with the same result.
Please help,
Viktor
Hi Viktorpopescu,
The problem is caused by known issue https://youtrack.jetbrains.com/issue/PY-27234. It should be fixed in 2019.1 version. We have just realised our EAP build which has a fix for it. Would you mind give it a try?
You can download it from https://www.jetbrains.com/pycharm/nextversion/
Hi,
I've recently downloaded and installed Pycharm V 2019.3 EAP for Python 3.7. I'm using it with Anaconda and I am running into the same issues above. When I type "import numpy as np" into the console and the editor, I see the same error
Traceback (most recent call last):
File "C:\Users\anagr\AppData\Roaming\Python\Python37\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-d4cdadb62aa7>", line 1, in <module>
import numpy
File "C:\Program Files\JetBrains\PyCharm Community Edition 193.4099.14\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\anagr\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Program Files\JetBrains\PyCharm Community Edition 193.4099.14\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\anagr\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\anagr\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
I've tried installing a different version of numpy, uninstall and reinstall Pycharm, nothing seems to work.
Thanks,
In general the cause of the problem could be the following:
You started new project with new virtual environment. So probably you install numpy from the terminal, but it s not in your venv. So
- either install it from PyCahrm Interface: Settings -> Project Interpreter -> Add the package
- or activate your venv and -> pip install numpy
Hello, noticed a similar problem on my end, found this by googling, and it's some what relevant.
It seems the scratch.py wasn't connected to the console pip installs as i thought it would, and everyone is suggesting the correct steps. I checked all those things, everything checked out.
One note, someone mentioned testing import works in console. this helped a bit.
i kicked off python in the same pip install console within pycharm 3.7 python project and was able to see the import numpy as np is working, a deeper dive I found making a python in the virtual environment directory was a quick work around to getting the imports to work in the python editor. granularity explained below.
excuse my mistakes, seems this might be more of a directory/access issue that is remediable when putting a python file in a different directory.
best,
tyler garrett
while installing the numpy , keras
library on the pycharm , the IDE shows this message
Please Help!!!
I created a new conda project interpreter to my project since I installed pytorch in it. It is detecting pytorch fine but is not able to detect numy through the anaconda interpreter but is able to do so with the python interpreter. Can anyone help me why it is not able to detect numpy even after it is installed in anaconda and runs perfectly fine in the anaconda prompt and not in pycharm.
Hello,
I am wondering how the numpy package has been installed? Do you see it in the list of packages in the Interpreter settings?https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
I am having issues with importing Numpy or even when i try to import it as import numpy as np . it's not working . i tried the steps that sergey said but it still doesn't work .
It shows this error when i run a basic program in numpy:
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
^
SyntaxError: invalid syntax
please help
Win 10 / python 3.8.1
Thank you

Your problem is not related to PyCharm in any way.
How did you install numpy?
I'd recommend creating a virtual environment and installing numpy in it.
Hey Gautamkhattri07,
If you can scroll up 4 comments, you will see what the correct install looks like and how I'm importing numpy is different.
Good luck.
Best,
Tyler
d3.is