Invalid Python SDK in PyCharm

Question:

Since this morning, I’m no longer able to run projects in PyCharm.

When generating a new virtual environment, I get an "Invalid Python SDK" error.
Cannot set up a python SDK at Python 3.11… The SDK seems invalid.

What I noticed:
No matter what base interpreter I select (3.8, 3.9, 3.10) Pycharm always generates a Python 3.11 interpreter.

I did completely uninstall PyCharm, as well as all my python installations and reinstalled everything.
I also went through the "Repair IDE" option in PyCharm.
I also removed and recreated all virtual environments.

When I run "cmd" and type ‘python’ then python 3.10.1 opens without a problem.

This morning, I installed a new antivirus software that did some checks and deleted some "unnecessary files" – maybe it is related (antivirus software is uninstalled again).

Asked By: user7431005

||

Answers:

Had the same issue just today. I was able to resolve it by uninstalling python 3.10.1 and then reinstalling it under directory "C:/Program Files" instead of the default directory where it goes.

There are many other fixes also suggested by people all over the internet such as:

  • Installing an older version of Pycharm i.e. 2021.2
  • Allowing the pycharmProjects folder in windows defender

But the change of installation directory is what worked for me.

Answered By: bmak

Dealt with the same issue despite using python and pycharm without issue for months. Recently kept giving me the error despite changing the PATH variable of my system and even manually pathing within pycharm. After hours of reinstalling pycharm, python and even jumping around versions with no success it turned out it was because my python directory had a space in it that it just randomly decided to break.

For anyone who has tried what seems like everything to no avail ensure that NO part of the path to your python directory contains spaces

Answered By: ANNIEWANNIE

I had the same problem on Linux. Solved it by invalidating caches as suggested here:
https://stackoverflow.com/a/45099651/3990607

In pycharm click on File menu, then choose Invalidate caches..., tick all 4 boxes and then restart PyCharm. Solved the problem for me.

Answered By: patapouf_ai

Python 3.10 version installed through windows store didn’t have any spaces in default directory names (as my username doesn’t have a space within itself).
I id invalidated caches through the file menu. However, patapouf_ai had suggested doing it for Linux.
The problem was resolved for me after installing and then reinstalling it through windows’ remove and store, and it seems it’s been caused by changing windows’ user account control level to "never notify." The other possibility is that somehow python 3.10 has stopped functioning without a good reason and lost recognition by windows (not updated or modified by any means).

Answered By: Ebrahim S.

using IDLE

import sys

print(sys.executable)

#output is a path to where the interpreter is, copy path

PyCharm / file / settings / Project / Python Interpreter / show all / paste path

Answered By: cometsurfer

I had the same issue. I got around it by installing an older version of PyCharm.

Answered By: Will-NotGiveUp

Check if your python executable is named python.exe!

I had the same problem and I solved it by going into C:Users<user>AppDataLocalProgramsPythonPython310. My python executable was named python3.exe, but Pycharm needs python.exe for some unknown reason. So I

  1. copied python3.exe,
  2. pasted it in the same directory and
  3. renamed it to python.exe, and all started working magically. Maybe just renaming will also work.
Answered By: Aleksei Asoskov

on Pycharm, click on up right corner search button –> wrire swştch python interpreter –> add new interpreter –> add local interpreter –> hit OK

Answered By: itssoelif

I had this same error on windows, none of the answers in this thread worked.
But i found a solution so i will share it.

Go to %appdata%/Jetbrains/ and search for jdk.table, backup the file and delete it (this will delete all your interpreters configs) close all your pycharm instances, and start them again. After that just add your interpreter like you normally would.

This is what worked for me.

Answered By: Cashz

I had this issue too. Python had been working fine for months and then suddenly stopped working. None of the other solutions worked for me.

The solution that worked for me was to uninstall Python then reinstall for all users. After doing this, I had no issues.

Answered By: Angoose

For me the solution was to update from Python 3.9 to 3.11. After setting virtual environment based on Python 3.11 the interpreter works without any error message.

Answered By: David Imre

I had the same issue. I simply removed the PyCharm and then re-installed it. My issue was resolved then.

Answered By: Asim
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.