rayonst
rayonst

Reputation: 423

Invalid Python SDK Error while using Python 3.4 on PyCharm

When I switch my PyCharm to use Python 3.4.3 and I am getting the error:

Invalid Python SDK

Also PyCharm does not automatically find the Python 3.4 interpreter for me, even though it is on the desired path /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4. See the screenshot:

prompt with error message

Despite this the interpreter does work. I am able to get correct output as expected, but code completion related to Python 3.4 is not working.

E.g. print("hello world!) still shows an error on the editor, but the console shows the correct output.

Upvotes: 41

Views: 133786

Answers (11)

Onyeka ojumah
Onyeka ojumah

Reputation: 1

I've solved it too. Uninstalled python 3.10, installed python 3.9. Changed the python interpreter to 3.9 through pycharm setting. Created a new virtual environment.

Upvotes: 0

Kevin Bozman
Kevin Bozman

Reputation: 1

I ended up having to install Python as an admin and make sure it installed to the C:\Program Files\Python310 folder. I think The option was to make sure it installed for all users. If I installed it under for user's appdata it wouldn't work.

Once I did that I was able to point pycharm to the C:\Program Files\Python310\ for the interpreter. Pretty annoying but finally got it working

Upvotes: 0

mcrrnz
mcrrnz

Reputation: 595

I got the same problem with Pop OS 21.04 and Pycharm installed via Flatpack. So i remove it and installed via Snap and started working again.

Upvotes: 0

cryptodaddy
cryptodaddy

Reputation: 1

When creating a new project my interpreter was set to python 2.7 so I had to change that to python3 and everything works like a charm

Upvotes: 0

Helena
Helena

Reputation: 11

I had the same issue in Windows10. I was so frustrated, beacause everything seems looked OK. I've added PYTHONPATH, I've restarted Pycharm and deleted old virtualenv folders and created new... It did't work.

And at the end I have just opened Pycharm in an administrator mode and it works!

Upvotes: 1

alex_555
alex_555

Reputation: 1102

For me, changing the paths in ~\venv\pyvenv.cfg made PyCharm recognize the new environment after bringing my projects to a new PC.

Upvotes: 0

osuwireless
osuwireless

Reputation: 655

I couldn't get anything to work, so I cloned my conda env (see how), called it something else, and then set it in PyCharm to the new one.

Upvotes: 0

gihanchanuka
gihanchanuka

Reputation: 5051

I got the same issue, when I updated Python (3.x) version via Home brew in MacOS. Above answers didn't work for me. But with those, I realize that, it's an issue with linking the directories. I deleted ~/.virtualenvs folder and recreated all virtual envs.

$ ls -a ~/.virtualenvs
local-dev wdias-dev
$ rm -rf ~/.virtualenvs
$ which python3
/usr/local/bin/python3
$ mkvirtualenv local-dev --python=/usr/local/bin/python3
$ mkvirtualenv wdias-dev --python=/usr/local/bin/python3

Open the PyCharm again, and it works fine.

Upvotes: 0

fedorqui
fedorqui

Reputation: 289835

This also happened to me. I renamed a repository and then my virtual environment got stuck in the old path.

I grepped all configuration files and could not find any reference to the old one.

What finally solved the problem was to clear caches with the option File > Invalidate Caches / Restart...:

enter image description here

Upvotes: 44

ldiary
ldiary

Reputation: 494

I go the same error message in Windows version of PyCharm after I re-installed Python (3.5) on a different location. The problem was that most of my existing virtual environments registered in PyCharm were still referencing the old installation of Python.

I resolved it by deleting these existing virtual environments and creating a new one. If deleting existing interpreters (in virtual environment) is not an option, you should be able to modify them instead in File | Settings | Project Interpreter

Upvotes: 3

mennanov
mennanov

Reputation: 1245

I had the same issue. Try to comment/remove the PYTHONPATH variable in your ~/.bash_profile

#export PYTHONPATH=/usr/local/lib/python2.7/site-packages/

If it does not help it also may be useful to look in the idea.log for the errors:

/Users/username/Library/Logs/PyCharm40/idea.log

I had the following errors:

Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x!
     PYTHONPATH is currently: "/usr/local/lib/python2.7/site-packages/"
     You should `unset PYTHONPATH` to fix this.

Upvotes: 9

Related Questions