'Set pythonpath in intellij
Where is the PYTHONPATH set in Intellij community edition 15.X?
Following shows where I have already looked:
Python interpreter:
Python SDK:
Global Libraries:
So .. I can not find where to set the environment variables for $PYTHONPATH. Funny thing - I recall having been able to do so in version 14 Ultimate Edition. Is this a CE version difference?
Solution 1:[1]
I arrive some four years late to this party ;-) but this is the solution I have just found to incorporate arbitrary directories in my project to the IntelliJ path for execution and import inspection:
TL;DR: The only thing you need to do is marking the directory containing the module you want to import as a 'Sources Root'
Some additional explanation: I was trying to make work an old LiEclipse project inside Intellij CE last edition and it was giving me hell because I couldn't find a way to modify the PYTHONPATH to add the folder containing the "DegreeDistributionsForGraphs" module I need
In the end I found it is as easy as marking the folder as a 'Sources Root', from that moment on import and execution resolution works properly
I'm using the last IntelliJ CE available (in fact downloaded today)
Solution 2:[2]
I believe what you are looking for is under Project structure->Modules->Dependencies->Module SDK which will be the python interpreter setup within Platform Settings->SDKs. You are also able to add additional paths to the Python SDK which I believe acts as the $PYTHONPATH.
Python Console:
I currently have CE16.1, however, it may be similar. I was able to find information under Build, Execution, Deployment -> Console -> Python Console within the Preferences to set different options such as Environment variables, Interpreter options etc. Intellij's page on Python console may help also.
Solution 3:[3]
Right click the project ---> "Open Module settings"
"Project Settings" ---> "Modules"
Click on the project
Click "+Add Content Root"
Add the path of the desired pythonpath reference.
After adding it, mark it as 'Resources'
Solution 4:[4]
You have to create a new Library (or Global Library) of type Java and add your path twice, under both Classes and Sources.
This will be used for imports and running tests.
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 | |
| Solution 2 | |
| Solution 3 | Sats |
| Solution 4 | akvadrako |






