I am using a remote Python interpreter (a virtual environment created using pew) that I access via ssh. This is working fine when manually ssh'ing to the server and using the interpreter. However when using PyCharm to call it, it forgets about the environment variables that I export in my .bashrc.
It seems when calling the Python Interpreter via ssh, PyCharm (even though started from bash) ignores the .bashrc. Here it is indicated that a shell wrapper is the solution.
#!/bin/bash -l
/path/to/interpreter/bin/python
But simply giving PyCharm this shell file as an Interpreter doesn't work (package management is disabled and when running py-code a Python terminal opens...).
How do I get a "shell wrapper" that makes sure .bashrc is executed before the PyCharm remote Python-interpreter is run?
I made sure that PyCharm runs with the correct environment. All local interpreters don't show that problem (testing in PyCharm terminal and with a Python script:)
import os
print(os.environ)
I am also aware of the "Edit Configuration" option for running specific files and the possibility to set environment variables there, however it is tedious to that for each project/file and not what I'm looking for.
解决方案
You want your wrapper to contain the "$@" when calling python in your wrapper:
#!/bin/bash -l
/path/to/interpreter/bin/python "$@"
With that trick I somehow managed to setup pycharm on Windows while using virtualenv in WSL (Ubuntu bash) and retrieving my WSL env variables.