Cannot import NumPy module in PyCharm (but it runs fine in the terminal window on Mac) and I keep receiving the below import error:

 

Traceback (most recent call last):   File "/Users/ishanp/PycharmProjects/APIcreation/API.py", line 1, in <module>     import pandas as pd   File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/__init__.py", line 16, in <module>     raise ImportError( ImportError: Unable to import required dependencies: numpy: Error importing numpy: you should not try to import numpy from         its source directory; please exit the numpy source tree, and relaunch         your python interpreter from there.

0
7 comments
Hello, 
Please copy the command from the first line of the error output and run it in the system terminal, take a screenshot, and post it here. 
If it produces no error, please also open Run | Edit Configurations, find the run configuration for your Python script, take a screenshot, and post it in the thread as well.
0

Its showing the same error to me as well. When importing pandas its showing the import error for numpy it was working perfectly fine some time back but now its throwing this error 

ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
       its source directory; please exit the numpy source tree, and relaunch
       your python interpreter from there.

 

thats the error it shows 
 

0

The error for me was resolved I simply uninstalled and reinstalled numpy thats what worked for me

0

Hi, I have encountered exactly the same error. Have tried reinstalling numpy but still no luck. Could you help advise please

0
How was the numpy installed in your interpreter? Could you please run pip list with your environment and copy the output here?
0

Hi there - thanks for coming back

I have used both terminal to install and install package in Python interpreter. Tried uninstall and install again but no luck

0
Is your environment created from the requirements file? If yes, could you please try re-creating it without defining specific package versions?
0

Please sign in to leave a comment.