'Invalid Python SDK in PyCharm
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).
Solution 1:[1]
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.
Solution 2:[2]
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.
Solution 3:[3]
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).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | patapouf_ai |
| Solution 2 | Dharman |
| Solution 3 | Ebrahim S. |
