53

enter image description here

I try to set up project interpteter Python 3.5 in Pycharm and get an SDK error?

Any solution to fix it?

Nathan Wailes
  • 9,872
  • 7
  • 57
  • 95
NibiruSpetsnaz
  • 533
  • 1
  • 4
  • 7
  • Did you just copy python34.exe to your desktop? Python is normally not installed into the desktop directory. – yole Jan 06 '16 at 17:27

13 Answers13

29

did you move the whole project after you open it with pycharm? if so, just remove the .idea/* (run rm -r .idea under you project)

This problem is caused by: pycharm will create a .idea file under the project after the first time you import the project. SO the path in there will remain the old one after you moved the project. Thus the pycharm will keep trying to import 'old_path/venv/bin/activate' which is kept in .idea/*

Yicheng Feng
  • 299
  • 3
  • 2
5

I had such problem. The solution was pretty easy. I created an account in russian in Windows, and you could emphasize that the error message (the big one) then contains the word about encoding is used. Therefore check your Windows account name - change it if it's not in english and contains spaces and other unwanted signs. Thanks.

Sergei Shumilin
  • 411
  • 5
  • 17
  • As of PyCharm 2022.2.2, PyCharm will still give you this error if you have a space in your Windows username or path to Python executable. I worked around this by making a symlink to the Python directory, without using spaces. – Albert S Nov 03 '22 at 18:43
4

I just had this error and got around it, and long-story-short I think it may have had to do with my PATH / PY_HOME / PYTHONPATH environment variables pointing to a different version of Python. Here's what I did:

Background:

  • In my case, I was trying to get a Python 2.7 venv running on a laptop where I'd previously been working with Python 3.
  • I'm using Windows 7.

Solution:

  1. Hit the Windows key to pop up the Start menu.
  2. Type out 'path' and hit Enter.
  3. The 'Environment Variables' window should appear.
    • There should be two sections of the window:
      1. One should say, "User variables for your_user_name".
      2. The other should say "System variables".
  4. In both sections of the window, look for and edit (if they exist) the PATH, PYTHONPATH, and PY_HOME environment variables.
    1. I removed any references to Python 3.
    2. I set the PY_HOME variable to C:\Python27 (or whatever the path is to the Python installation you're trying to get working in PyCharm.)
  5. I also deleted my installation of Python27 and reinstalled it, but I'm not sure that that was necessary.
  6. Restart PyCharm.
Nathan Wailes
  • 9,872
  • 7
  • 57
  • 95
2

I got the same problem on windows 10, and got the solution.

PyCharm_Python_error.png

Root cause: - Python cannot be launched due to no python27.dll.

Solution: - Install python or put python27.dll in PATH

Thanks.

Lon
  • 21
  • 3
2

In my case, python.exe that I had in my venv was the problem.

Thus, I downloaded a specific version of Python and pasted contests of its Script folder to my \venv\Scripts folder.

Başar Söker
  • 606
  • 8
  • 16
0

A fix for this issue, is tell to the global var named-> LD_LIBRARY_PATH to include the new python libraries compiled. Let's assume that you have just download python, extracted it & installed; assume that you have downloaded the 3.6.4 version

For include the library, you have to edit your .bashrc file. (This file is quite interesting, have a look ;) ). This file is an "hidden file" placed in your home: nano ~/.bashrc is a quite easy text editor. Go at the end of the file and append this command, replacing your path of new python export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/whoami/Downloads/Python-3.6.4

CTRL+X for save file.

For load the new file:

source ~/.bashrc

alessiosavi
  • 2,753
  • 2
  • 19
  • 38
0

Operating system: Windows 10 / cygwin

Desired Python: 2.7.14

Error: "SDK seems invalid"

My fix:

  1. Remove Python 64 bit version
    1. Install Python 32 bit version
    2. using the windows environment variable dialog set PY_HOME={somedrive}\{somepath}\Python27
      PYTHONPATH={somedrive}\{somepath}\Python27

note: I guess it works since the errors I see are python generated eg "Traceback (most recent call last): File ..."

freeislandguy
  • 119
  • 1
  • 1
  • 7
0

I just ran into the same problem with Python 3.6 (which I wanted to use) and Python 3.7 also installed in my computer. My solution was just to remove reference to Python 3.7 from System PATH.

So my PATH is currently set:

C:\Program Files\Python36\Scripts\
C:\Program Files\Python36\

That's all, hope it helps.

Christine
  • 25
  • 6
0

I had the same issue. I suspect it occurred whilst i was doing a python project, I was trying to make tensorflow run on my GPU, messing with settings I didn't and still dont really understand (in the terminal with path variables)

The issue in my case was with my system interpreter. I fixed it by going to the interpreter section in Pycharm and creating a choosing a new interpreter. I edited the "Path" environment\system variables from "...\python.exe\Scripts" to "...\python.exe"

Javonne
  • 39
  • 9
0

In my case (on a Windows os), the problem was due to the fact that I added a PYTHONHOME environment variable in an unrelated test of Apache2.4 + Flask: That "broke" the set up virtual environments using Conda. I started to get the "invalid SDK" error described above when I created a virtual environment which needed a version of Python different from the one indicated in PYTHONHOME (in my case, I needed a virtual environment running Python 3.6, while PYTHONHOME pointed to 3.8 version).

Solution: I simply needed to remove the PYTHONHOME environment variable!

nikeros
  • 3,302
  • 2
  • 10
  • 26
0

This work for me:

My environment created with python 3.9.1 but I install python 3.8 when I uninstall python 3.8 then restart and install python 3.9.1 version that set up in Pycharm correctly.

Note: After uninstall its important restart OS then after restart install python version compatible with environment created .

henrry
  • 486
  • 6
  • 25
0

For me, the problem was that part of the path of the project was in Hebrew, so when I changed it to English the problem was solved :)

Ohad Sharet
  • 1,097
  • 9
  • 15
-1

PyCharm picks up random files of format ~/.asdfqwer/python as the Python executable or environment

On Ubuntu 19.04 pycharm-community 2019.2.3 installed with the snap, PyCharm for some weird reason picks up anything with the form:

~/.asdfqwer/python

up as a virtualenv Python interpreter and uses that as the default.

In my particular case, I had a file called:

~/.gdbinit.d/python

for my GDB Dashboard, which is not at all a python interpreter or virtualenv, just a python GDB config as opposed to a .gdb config.

To solve it, I just had to set the correct interpreter at:

  • File
  • Settings
  • Project: <project-name>
  • Project Interpreter
  • Dropdown with the random python interpreter selected
  • Show all
  • Delete the random interpreter wit -
  • Add the correct interpreter with +

enter image description here

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985