Python Forum

Full Version: Pandas - error when running Pycharm, but works on cmd line
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm having problems running scripts that reference pandas when I use Pycharm, but when I run the python scripts on the command line, then it all works fine.

For example, I have a basic test program which has nothing more than this :

import pandas
print ('Hello')

In Pycharm I get this error msg (see attachment).

My Python version is 3.8, and my Pycharm version is in the attachment.

I can successfully run this from the command line as follows :

C:\Users\hsdhi\PycharmProjects\pythonProject>python aa.py
Hello



....and under this structure I have a pandas directory.

I suspect that my version of Pycharm is somehow out of sync with the pandas. I've removed and reinstalled pandas many times but get the same error.

All advice greatly appreciated.
You are using virtual environment pythonProject\venv doc venv.
PyCharm can make venv automatically.
To use same Python interpreter as you use cmd look at Configure a Python interpreter
Do this from cmd:
C:\>python -c "import sys; print(sys.executable)"
C:\python310\python.exe

C:\>pip -V
pip 22.0.4 from C:\Python310\lib\site-packages\pip (python 3.10) 
Then look at Setting the default interpreter in link,
here you point to first output in cmd so for me this is C:\python310\python.exe for you it can be different.
Then PyCharm will use this Python interpreter every time you create a new project.