Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does PyCharm sometimes not use system environment variable for PATH with a virtual environment?

Using PyCharm, I have configured a virtual environment. This results in some really confusing interactions with PATH. When I look at the environment variable for PATH that a file has:

print '##### PATH'
print os.environ['PATH']

I see the following output:

##### PATH
 /usr/bin:/bin:/usr/sbin:/sbin:/Users/username/.virtualenvs/venv/bin

This confuses me because I have explicitly told PyCharm to use system environment variables through the following dialog:

enter image description here

When clicking "Show" I see that PATH is defined differently:

enter image description here

What I do not understand is:

  1. Running PyCharm from a shell using charm results in PATH being successfully set:

    ##### PATH
    /Users/username/.virtualenvs/username/bin:/Users/username/go/dependencies/bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/bin:.... etc
    

    This is without any other configuration taking place in PyCharm - simply relaunching it from a shell causes PATH to behave set differently

  2. I can also manually define the PATH variable in PyCharm (to the value given in the parent environment variables tab) and it works fine, too

But for some reason PyCharm is not pulling the PATH variable from my parent environment variables even though it is present and appears to be included properly (without either of the above two workarounds).

Why is PyCharm doing this and what do I need to do to actually "include parent environment variables" correctly?

I am using PyCharm 5.0.4 on OS:X with a bash shell.

like image 622
enderland Avatar asked Mar 22 '16 17:03

enderland


1 Answers

It is a known bug in pycharm and OS X: https://youtrack.jetbrains.com/issue/PY-17816

like image 200
slallum Avatar answered Oct 02 '22 14:10

slallum