Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDK is not defined for Run Configuration

Tags:

python

pycharm

When I'm trying to run my project in PyCharm I'm getting an error:

SDK is not defined for Run Configuration.

I tried to set a new interpreter and tried everything.

What does "SDK" mean and where can I configure it?

error popup on run button

like image 388
NatiFo Avatar asked Dec 04 '25 05:12

NatiFo


2 Answers

I just had this same issue (see my comment above). What worked for me was to go into "Edit Configurations", delete the configuration that was copied over from the original PC, and create my own configuration (basically with the same inputs as before).

like image 144
Tom Johnson Avatar answered Dec 06 '25 19:12

Tom Johnson


This might happen if a run configuration was imported from another computer.

Run configuration can contain a path to a Python interpreter from that computer.

By default, run configurations are stored in .idea/runConfigurations/*.xml.

If you pull up .idea/runConfigurations/<your-configuration>.xml you'll probably notice a fixed path to the Python interpreter somewhere in there, e.g.:

<option name="SDK_HOME" value="$USER_HOME$/.local/share/virtualenvs/your-project-name-XXXXXXXX/bin/python" />

alongside with

<option name="IS_MODULE_SDK" value="false" />

It that's true try changing those lines to

<option name="SDK_HOME" value="" />
<option name="IS_MODULE_SDK" value="true" />

This will make your IntelliJ IDE look for Python in your local project's virtual environment folder.


Basically, like folks have already mentioned before, simple recreation of your run configuration by hand will help because it will disregard other machine's settings and apply yours, but sometimes it may cumbersome (especially, if your run configuration contains some project-specific environment variables and other stuff which can be tedious to copy over).

So, just changing those two lines in the run configuration XML file should help without recreating it manually again from scratch.

The nastiest thing about this situation with Python path is that when you import a run configuration for a Python project from another machine with Python path being hardcoded PyCharm will still keep showing you yours in the Edit Configurations window making it really hard to track down and fix, so in this very specific case don't believe what you see in the run configuration UI -- just go and check the run configuration XML config behind.

like image 37
Mαx Φ Avatar answered Dec 06 '25 19:12

Mαx Φ