6

I have PyCharm 2.7.3 installed on Windows, and I am trying to remotely develop an application on a Linux machine.

So far I can run simple programs, however I'm trying to set my PYTHONPATH and it seems that PyCharm specifically ignores this configuration.

Under my run configuration, I've tried setting PYTHONPATH=/path/to/my/libs, however if I print this environment variable from Python through os.environ, it is ignored. If I set another environment variable, for example ASDF=42, the value is printed as expected - so it's something special with PYTHONPATH.

Under interpreters, I tried adding it under the Paths tab, but this tab only supports Windows paths, so it seems to be local only.

import os

if __name__ == '__main__':
    print os.environ['PYTHONPATH']
    print os.environ

The output of the first line of this program changes based on check boxes in the run config, all with PYTHONPATH=/path/to/my/libs

With Add content roots to PYTHONPATH and Add source roots to PYTHONPATH checked, and PYTHONPATH=/path/to/my/libs, the first line of output is the remote root of my project - but still not my lib directory.

If I uncheck the source roots box, the path remains empty (but the variable is set, to the empty string).

What am I doing wrong?

1 Answer 1

3

I believe this is a bug in PyCharm, but in the meantime, I've found a workaround.

The heart of the issue is that with a remote interpreter, the Path configure dialog is for the local machine, not the remote machine. So the solution is to set up deployment to the remote machine, and map local folders to path folders on the remote machine.

In the paths tab, add empty windows folders to your project, representing each of the lib directories, then in Tools -> Deployment -> Configuration, map those directories to your lib directories.

ie. if you have a lib in /my/fancy/python/lib, create a folder C:\IdeaProjects\MyProject\my_fancy_python_lib, and then create a mapping to /my/fancy/python/lib in the deployment configuration.

Hacks, but it works.

Someone filed a bug report for it here (I posted my answer there too): http://youtrack.jetbrains.com/issue/PY-10739

Sign up to request clarification or add additional context in comments.

1 Comment

that ticket was never closed, but a related one was fixed; youtrack.jetbrains.com/issue/PY-15571 PY-15571 cannot add interpreter paths for remote interpreters Is duplicated by: PY-16521 I configured several local and remote interpreters. When I want to update paths on remote interpreters, I can only delete paths, not add.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.