'Invalid Python SDK Error while using python 3.4 on PyCharm
When I switch my PyCharm to use Python 3.4.3 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 desired path /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
.
See screenshot:
Although 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.
Solution 1:[1]
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.
Solution 2:[2]
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...
:
Solution 3:[3]
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
Solution 4:[4]
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.
Solution 5:[5]
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.
Solution 6:[6]
For me, changing the paths in ~\venv\pyvenv.cfg
made PyCharm recognize the new environment after bringing my projects to a new PC.
Solution 7:[7]
I solved the same problem by uninstalling and re-installing PyCharm. Try it. It's waaaay simpler.
Solution 8:[8]
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!
Solution 9:[9]
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
Solution 10:[10]
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.
Solution 11:[11]
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
Solution 12:[12]
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.
Solution 13:[13]
I resolved the same issue easily. I just added the versiĆ³n of python manually.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow