We are using PyCharm as the Python IDE for a project. Developers use different kind of OS setup, e.g., python path is not the same for some of us (some have local interpreter stored at different location or remote interpreters).
Unfortunately, python interpreter path is stored in the .idea PyCharm project folder (.iml file). It then leads to conflicts or python path overriding when merging branches with Mercurial.
We would like to keep tracking under version control the .idea folder and the .iml file since they do hold meaningful settings that should be shared across developers (but the python path).
Is there a way to setup the python interpreter path outside the PyCharm project?
Note: There's an interesting SO question (Share a PyCharm project across multiple operating systems (different interpreter paths)) but it force developers to rename their interpreter entry (and have a single interpeter) for all their other projects.
You can somewhat abstract explicit Python interpreter location from your project by using virtualenv and agreeing on the common name between developers. This solution is is an extension of the mentioned SO question.
Set-up workstation:
Create virtual environment:
Set up the interpreter in PyCharm:
.idea
contains only the interpreter name, not the location:Now, when the the project is opened a workstation first time, it will error out and complain that "Invalid Python interpreter selected for the project". Developer will have to point "we-all-agreed-on-that-name-interpreter" to local virtual environment and make sure that "Associate this virtual environment with the current project" checkbox is on.