Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm set the correct environment variable PATH

I'm executing with pycharm the following:

print(os.environ["PATH"]) # returns '/usr/bin:/bin:/usr/sbin:/sbin'

But when I execute echo $PATH in a shell this is returned:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/local/sbin

I tried to edit it in Preferences > Console > Python Console > Environment Variables, setting

PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/local/sbin

but this is not working

any idea?

like image 615
fj123x Avatar asked Feb 05 '14 15:02

fj123x


1 Answers

On Ubuntu, using zsh, I stumbled upon the same problem.

The hack I use in order to have the same environment variables in PyCharm and my shell is to launch PyCharm from my terminal instead of using the icon. It looks like this way that the PyCharm shell inherits from the main shell it's been launched from.

I hope it can solve other people's problem as I wasn't able to replicate @Steve Tarver's solution on Linux (.../terminal/.zshrc was read only on /snap/, even when using sudo).

like image 97
Pierre Gourseaud Avatar answered Sep 17 '22 20:09

Pierre Gourseaud