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
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

I've uninstalled & installed using pip as well as the IDE.  They same behavior.  It works from the command line python3 but not IDE.  The IDE generates the error above.   Something so sophisticated is somehow tripped. 

Please advise … yes, rebooted too.

0

This worked for me:

pip3 freeze | sort  > requirements.txt  
pip3 uninstall -r requirements.txt  
arch -arm64 pip3 install -r requirements.txt
 

0

请先登录再写评论。