Sharing Virtual Environment across machines (Python plugin)

When defining a Python project in IntelliJ IDEA using the Python plugin, one needs to specify the "Python SDK". When using virtual environments, it's a good practice to keep them project-specific, so that each project manages its own environment and set of libraries. With IntelliJ, however, the definition of a virtual environment is a machine-specific setting, while the association of a project with an environment is maintained in the project file.

What is the recommended way of sharing an python project in IntelliJ across machines and multiple users (e.g. via source control), while standardizing on the same virtual environment location (e.g. within the project structure)?

Note that I don't ask about the virtual environment *contents* (leaving that to other tools, e.g. Canopy or Anaconda), but merely its location relative to the project root.

9 comments
Comment actions Permalink

For the Python interpreter you have to rename it when adding so that it's stored in the project under the same name for all the users. By default interpreter name includes the full path, but it's just a name that can be changed, same as JDK name.

Actual locations are stored per user in IDE settings, project files contain only name reference of the SDK.

0
Comment actions Permalink

Hi Serge, thanks for your quick reply. Is there a way to share the actual locations too, i.e. make it a project setting rather than IDE setting (using relative paths)?
Alternatively, is there a file/script/registry setting we could use to automate the IDE SDK settings on all machines, so that we can safely share the same Venv name?

0
Comment actions Permalink

No, the actual paths are stored per user in IDE settings and there is no easy way to share them at the moment, see https://youtrack.jetbrains.com/issue/IDEA-103292 .

0
Comment actions Permalink

Thanks again.Would you recommend us any way of automating the IDE setup (e.g. editing some known file, calling some script or API, adding some registry entries) or should we rather ask every user to set up the SDKs manually?

0
Comment actions Permalink

Thanks again.Would you recommend us any way of automating the IDE setup (e.g. editing some known file, calling some script or API, adding some registry entries) or should we rather ask every user to set up the SDKs manually?

0
Comment actions Permalink

It's stored in XML file under config folder (https://intellij-support.jetbrains.com/entries/23358108). Look for options/jdk.table.xml. You can configure it on one machine and then distribute to other users.

0
Comment actions Permalink

Brilliant! Thank you, Serge!

0
Comment actions Permalink

Thanks again for your help earlier. When I tried to automate the setup, I encountered the following lines in the environment XML definition:

 <root type="simple" url="file://$APPLICATION_PLUGINS_DIR$/python/helpers/python-skeletons"/>
 <root type="simple" url="file://$USER_HOME$/.IntelliJIdea14/system/python_stubs/1568261787"/>

Please could you shed some light on what these represent, in particular what the second one means and how to derive it? The number seems to be different for each user/project?

Thank you!

0
Comment actions Permalink

This folder contains generated stubs for Python inetrpeter and its name would be random.

0

Please sign in to leave a comment.