Pycharm not finding python interpreters in non-standard locations

Answered

I have installed pycharm in a University Linux system. This is a "global" installation that many will be using and we're trying to set sensible defaults for users.

One problem that I have encountered is that pycharm only seems to find python interpreters that are installed in standard locations (like /usr/bin/python).

I know it is easy to add interpreters in the GUI, but for example we would like students to have python3 as default when they start pycharm for the first time.

Is this possible?

The version of pycharm we are using right know is 2019.1.2  on Redhat Enterprise Linux 7.

 

 

2 comments
Comment actions Permalink

One way to do it (if I correctly understand your case) is to prepare jdk.table.xml file up front where PyCharm stores information about the available interpreters. It is located in ~/.PyCharm<VERSION>/config/options/, new entries are added after a user specifies a new interpreter in the IDE. You can create (or copy an existed) jdk.table.xml with the desired interpreter configured, this way a user will see the interpreter in the list of existed. E.g., the following jdk.table.xml

<application>
<component name="ProjectJdkTable">
<jdk version="2">
<name value="Python 3.6 (test_2019_1_rc_pyramid)" />
<type value="Python SDK" />
<version value="Python 3.6.7" />
<homePath value="$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/bin/python" />
<roots>
<classPath>
<root type="composite">
<root url="file:///usr/lib/python3.6" type="simple" />
<root url="file:///usr/lib/python3.6/lib-dynload" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages" type="simple" />
<root url="jar://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/setuptools-39.1.0-py3.6.egg!/" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/pip-10.0.1-py3.6.egg" type="simple" />
<root url="file://$USER_HOME$/PycharmProjects/test_2019_1_rc_pyramid" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/waitress-1.2.1-py3.6.egg" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/pyramid_debugtoolbar-4.5-py3.6.egg" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/repoze.lru-0.7-py3.6.egg" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/pyramid_mako-1.0.2-py3.6.egg" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/Pygments-2.3.1-py3.6.egg" type="simple" />
<root url="file://$USER_HOME$/.virtualenvs/test_2019_1_rc_pyramid/lib/python3.6/site-packages/Mako-1.0.7-py3.6.egg" type="simple" />
<root url="file://$USER_HOME$/.PyCharm2019.2/system/python_stubs/-629381713" type="simple" />
<root url="file://$APPLICATION_HOME_DIR$/helpers/python-skeletons" type="simple" />
<root url="file://$APPLICATION_HOME_DIR$/helpers/typeshed/stdlib/3" type="simple" />
<root url="file://$APPLICATION_HOME_DIR$/helpers/typeshed/stdlib/2and3" type="simple" />
<root url="file://$APPLICATION_HOME_DIR$/helpers/typeshed/third_party/3" type="simple" />
<root url="file://$APPLICATION_HOME_DIR$/helpers/typeshed/third_party/2and3" type="simple" />
</root>
</classPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional />
</jdk>
</component>
</application>

with one configured interpreter from ~/.virtualenvs/test_2019_1_rc_pyramid/bin/python, this is how it will be show in New Project window in Pycharm:

Make sure to close IDE before manually changing xml files.

0
Comment actions Permalink

Thanks for this suggestion!

0

Please sign in to leave a comment.