I want to call an app from its bash command using Python. I added the path to the app to the PATH environment variable, so that this work in the terminal. However, when doing this in Pycharm, it does not work. I discovered, that is because apparently the environment variables are not all loaded in, when I call the app in Pycharm.
This is what I do in the terminal:
(save) philipp@philipp-Blade-15-Advanced-Model-Early-2020:~$ python Python 3.8.2 (default, Mar 25 2020, 17:03:02) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ["PATH"] '/home/philipp/anaconda3/envs/save/bin:/home/philipp/anaconda3/condabin:/home/philipp/sumo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin' When I run the same command in Pycharm, I get this output:
'/home/philipp/anaconda3/envs/save/bin:/home/philipp/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin' The output from Pycharm is missing /home/philipp/sumo/bin which is where I installed my app and where I need to call it from. I looked into this a lot, but could not figure out what the issue would be... I am using the same Anaconda environment in both cases. Can you point out the issue?
/home/philipp/sumo/binis added by your shell's configuration files. PyCharm isn't being started by your login shell, and so doesn't inherit a path containingsumo/bin./home/philipp/sumo/bintoPATHin the .bashrc file. Can you tell me, how I can use the same shell which the terminal uses in PyCharm as well? Also, in Windows this was working by default, I only came across the problem in Linux..bashrcis loaded intoos.environon login. Evidently that cannot be true..bashrcis sourced when your shell starts. But PyCharm doesn't have your shell as the parent; it basically gets executed for you by another process, so it doesn't inherit from your login shell.