Set pythonpath in intellij

Viewed 9008

Where is the PYTHONPATH set in Intellij community edition 15.X?

Following shows where I have already looked:

Python interpreter:

enter image description here

Python SDK:

enter image description here

Global Libraries:

enter image description here

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?

4 Answers

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

enter image description here

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

enter image description here

I'm using the last IntelliJ CE available (in fact downloaded today)

enter image description here

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'

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.

Related