Invalid Python SDK error when using python 3.4 in PyCharm

When I switch my PyCharm to use Python 3.4.3, I get the error:

Invalid Python SDK

Also, PyCharm doesn't automatically find the Python 3.4 interpreter for me, even if it's in the right path /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4

.

See screenshot:

enter image description here

Although the translator works. I can get the correct output as expected, but completing Python 3.4 related code doesn't work.

For example, it print("hello world!)

still shows an error in the editor, but the console shows the correct output.

+11


source to share


4 answers


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

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

      

If that doesn't help, it might also be helpful to look at the error .log idea:



/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.

      

+4


source


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

I copied all the config files and couldn't find any reference to the old one.



Ultimately the problem was resolved by clearing the caches using the " File > Invalidate Caches/Restart...

:

enter image description here

+9


source


I am going to the same error message on the Windows version of PyCharm after I installed Python (3.5) again in a different location. The problem was that most of my existing virtual environments registered with PyCharm still referenced an old Python installation.

I resolved it by deleting those existing virtual environments and creating a new one. If removing existing interpreters (in a virtual environment) is not an option, you should change them instead in File | Settings | Project translator

+2


source


I faced the same problem when I was updating the Python (3.x) version via Home brew on MacOS. The above answers didn't help me. But with that, I understand that this is a directory linking issue. I deleted the folder ~/.virtualenvs

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 PyCharm again and it works great.

0


source







All Articles