Pycharm terminal is missing part of $PATH

 

OSX terminal:

> echo $PATH

/Users/kart/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

PyCharm terminal:

> echo $PATH

/Users/kart/bin:/usr/bin:/bin:/usr/sbin:/sbin

 

/usr/local/bin is missing in PyCharm terminal's $PATH.

 

My configuration:

The "Shell path" in PyCharm is set to: /bin/bash --rcfile ~/.pycharmrc

and the content of my .pycharmrc is just: source ~/.bash_profile

Putting an ECHO statement into my .bash_profile shows it gets executed when I start the terminal in PyCharm.

 

 

24 comments
Comment actions Permalink

If you use ZSH as default shell, uncomment the first line of ~/.zshrc file to add the values to path variable. Is is default commented.

 # If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH

7
Comment actions Permalink

The problem seems to happen only with "shell integration" enabled.

If I uncheck Tools > Terminal > "shell integration" terminal will load normally, with full $PATH and normal settings.

6
Comment actions Permalink

Potential Solution/Workaround:  (see StackOverflow)

 

Add your user's rc file to your Shell Path in:

    PyCharm Preferences --> Tools --> Terminal --> Shell path

 

I created a .pycharmrc file that sources the various files that I need for my projects (virtual environments, paths, etc).  This is what I added to my Shell path setting in PyCharm:

    /bin/bash --rcfile ~/.pycharmrc

 

 

5
Comment actions Permalink

Same problem here. Using Zsh.

Seems that when Zsh is run from PyCharm, it's not loading the startup files

$ZDOTDIR/.zshenv
$ZDOTDIR/.zprofile
$ZDOTDIR/.zshrc
$ZDOTDIR/.zlogin
$ZDOTDIR/.zlogout

But If launch PyCharm from the shell (using the charm command), it seems it inherits correctly all the environment variables and the terminal tool in PyCharm works flawlessly.

OS: OSX 10.11

PyCharm 2016.3.2
Build #PY-163.10154.50, built on December 28, 2016
JRE: 1.8.0_101-b13 x86_64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

2
Comment actions Permalink

There is a known issue https://youtrack.jetbrains.com/issue/PY-17816 (PyCharm drops "/usr/local/bin" from PATH) in Pycharm bug tracker, please comment/vote for the issue to increase its priority and be notified about updates.

2
Comment actions Permalink

I'm experiencing the same problem as OP but it seems for different reasons.

Everything was working on 2016.2, stopped working on 2016.3. I use zsh.

Putting an echo in my .zprofile shows that it doesn't get executed. So /usr/local/bin isn't present in the path which leads to lots of problem.

1
Comment actions Permalink

Keeps failing.

2016.3.1 didn't fixed it at all.

1
Comment actions Permalink

PyCharm Community Edition 2016.2
Build #PC-162.1237.1, built on July 20, 2016
JRE: 1.8.0_76-release-b216 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

0
Comment actions Permalink

Encountering this issue on 2016.3

It seems the bash environment uses a PyCharm default path instead of the system's path. e.g. In addition to /usr/local/bin my Anaconda path is also missing.

0
Comment actions Permalink

Same issue here:

PyCharm 2016.3, Mac OS X 10.11.6

Path in the OS X Terminal App : /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin

Path in the PyCharm terminal : /usr/bin:/bin:/usr/sbin:/sbin

No ~/.bash_profile, shell path in PyCharm: /bin/bash (default value)

(And everything worked well just before the update to 2016.3)

0
Comment actions Permalink

thanks. do you know return default terminal as the userid-MacBook-Pro:mercury userid$?

0
Comment actions Permalink

@You6878 I feel like I'm unable to understand the question correctly.  I think you are asking about the user_id of the terminal.  If you are asking about the user_id for the terminal then it will be your current user_id since your user process launched it.  If you need to do some fancy setup or run a shell script to change conditions you can write that into your .pycharmrc file.  It gets executed with the --rcfile flag so anything inside will run.  This is why you can assign custom virtual environments to your shell.  Somewhere in your .pycharmrc (or whatever you call it) file you activate your virtual environment.  Likewise you can call source on your user's ~/.bashrc or ~/.bash_profile file and it will fix up your path and environment variables.

If I missed the question's goal then clarify how it was phrased and I'll see if I can offer any suggestions.

0
Comment actions Permalink

I think You6878 wants to know how to customize his command prompt in the terminal. To do this, add this line to your ~/.bashrc file (if you don't have a .bashrc file in your home directory, create one):

export PS1="\u-\h:\W \u$ "

 

 

0
Comment actions Permalink

Or maybe You6878ask why you don't get the exactly same integrated terminal in PyCharm than the one you get when using the "Terminal" app. (Because before PyCharm 2016.3 they was exacly the same, with the same path, etc). For example in the macOS terminal you have a  "<machine>:<path> <user>$" prompt but now you just have "bash-3.2$".

For me this all thing is a regression bug, as you loose features that you had in the previous version...

0
Comment actions Permalink

It solves the problem for me too.

0
Comment actions Permalink

I'm having a similar issue. I use RubyMine normally, in which the terminal works just fine, but when trying to load the terminal in PyCharm, it errors (specifically, it complains about not being able to find `thefuck`, which is a tool referenced in my `.zshrc` file).

Using Federicojama's suggestion of unchecking shell integration didn't work, but Luis Benitez's suggestion of launching pycharm from the shell does work.

0
Comment actions Permalink

The above solution worked for me. Thanks 096103006!

0
Comment actions Permalink

What  worked for was in zsh was to change the shell command to `zsh --login --interactive`. This will trigger loading /etc/zprofile and related paths for login shells.

There's probably a similar command for bash.

0
Comment actions Permalink

Still have some issues with pipenv inside zsh in PyCharm terminal. Here is an example:

 

 

PyCharm 2018.3.5

0
Comment actions Permalink
Hi, Thank you for contacting JetBrains support. Kindly provide additional information. I can see on the left screenshot that pipenv shell is started with "Shell integration" enabled. I assume this is the expected behavior? If so, doesn't leaving shell integration enabled solves the issue? Please provide more information.
0
Comment actions Permalink

On the left screenshot "Shell integration" is enabled and after starting Pipenv shell helpers zsh stops working - this is the wrong behavior. Only when "Shell integration" is disabled Pipenv starts as in other consoles (iTerm2 for example) and zsh features are available.

So, again, I should disable the "Shell integration" feature to use zsh + pipenv.

0
Comment actions Permalink
Hi, Unfortunately I can't reproduce the issue - `pipenv shell` inside zsh works correctly for me and I can zsh features afterwards. Please provide the following additional information: - Are you running PyCharm as a root? Please try so if not. - Do you have `oh-my-zsh` installed for your shell? - Is everything working correctly if you run pipenv shell in zsh in your system terminal outside of IDE?
0

Please sign in to leave a comment.