python - Environment $PATH different when using venv -


i'm using pycharm on mac (osx mavericks) run simple script shown below. print path variable. have virtualenv in project directory. added run configuration in pycharm , tried different pythons:

# file mytest.py import os print "path: ", os.environ['path'] 

when run system default python (/usr/bin/python) prints correct value path (i.e. path have configured in .bash_profile file,) kind of long , contains many directories.

but when choose venv's python, path reduced only: /usr/bin:/bin:/usr/sbin:/sbin:/users/myname/projects/myproj/venv/bin

this doesn't happen if run script terminal window. in case shows correct path both system's python , venv python. doesn't happen if deactivate venv , run venv/bin/python mytest.py.

anyone knows how make correct path value set when running pycharm , using venv?

you should know environment variables inherited. when define environment variable in .bash_profile becomes available in terminal (bash), , in processes started terminal (these processes children bash process). that's why getting expected values when running script within terminal.

you start pycharm not terminal, doesn't inherit path. , python or venv (they launched pycharm).

to solve issue have 3 options here: start pycharm terminal or move path variable definition .bash_profile session init scripts (path defined system-wide) or duplicate path in pycharm's run configuration (it has such option on there)

good luck!


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -