How to set a remote virtualenv as the python interpreter?

When I go to Settings -> Project Interpreter -> Python Interpreters, I can either assign a local or remote python interpreter, or a local virtualenv. There doesn't appear to be an option to assign a remote virtualenv. Why is this? Am I missing something? I would prefer to keep my remote projects within their own virtual environments.
8 comments
Add your remote virtualenv as a remote interpreter and point to a virtualenv's python executable (like this: <Your virtualenv root>/bin/python).
0
This approach works for me, but with issues: PyCharm can't find imports from within the remote virtualenv.

E.g. remote interpreter –> <virtualenv_root>/bin/python
<virtualenv_root>/lib/python2.7/os.py exists, but when I "import os" I get red squiggly line –> "no module named os".

In contrast, when I use the systemwide remote interpreter (/usr/bin/python) such imports resolve normally and I can view their source.

This is PyCharm 3.4.1.
0

I know this is an older issue, but I am running into the same challenge with PyCharm version 2017.2.  

I was able to successfully configure my remote virtual environment, however the remote virtual environment does not source the '$WORKON_HOME/bin/activate' file.  I have set a couple of environment variables in the $WORKON_HOME/bin/activate' file.  If I SSH into the remote system, then execute 'workon python3.6' the environment variables are set correctly.  But, when I run a test case in PyCharm using the remote virtual environment as the interpreter, the environment variables are not set.

It seems PyCharm finds all of the virtual environments python packages, but does not find the environment variables.  Unless I am missing something that is.  Can you please advise on how to correct this issue?

1

Does anyone have a solution to this?  The remote function has the potential to be incredibly useful, but complete support for remote environments is critical.

2

That feature would be great, sadly it still doesn't exist :(

0

Is this solved in PyCharm-2018? 

0

Hi Thomas, there're multiple problems described in this thread, which one do you refer to? In general case everything should work - you can add a virtual environment on the remote machine as an interpreter in PyCharm. Meanwhile, PyCharm does not source activate, but it should not bother you until you edited the activate script by hand. It is also impossible to create a venv on the remote machine with PyCharms' UI.

0

Please sign in to leave a comment.