4

I just installed Python 3.6 from python.org on macOS Sierra.

Somehow, the path to python's bin is added to my every $PATH but I can't figure out how:

22:15 : echo $PATH                                                                          
/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Library/TeX/texbin

Now, /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin is the default value in my /etc/paths and the X11, git and TeX parts come from the 3 files in /etc/paths.d/. But I have no Python-related file in /etc/paths.d/.

And there is nothing related to Python in my ~/.zshrc.

Does anyone know where the Python bit of $PATH is coming from?

  • hat is in ~/.zprofile and ~/.zlogin and does this PATH show in a new shell? and what is in ~/.bashrc – user151019 Mar 19 '17 at 18:37
  • What are the results of cd; grep 'PATH' .z*? – fd0 Mar 19 '17 at 19:18
  • @Mark: bingo, Python modified (actually created) ~/.zprofile!! If you make it an answer I'll accept it. – Alexandre Halm Mar 20 '17 at 2:55
3

zsh reads from up to 4files on start up

If ZDOTDIR is not set, then the value of HOME is used; this is the usual case.

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

You need to look in all of them.

.zshrc is read every time a shell or sub shell is started. .zprofile is read when you start a login shell - ie the first shell you start through terminal, and this is where I would put the PATH changes

-1

Check ~/.bashrc or ~/.bash_profile

  • .bash_profile (.bashrc isn't common on macOS) is specific to Bash; the OP appears to be using Zsh. – John N Mar 19 '17 at 19:30
  • Last time I had the same issue, I found I sourced bashrc in zshrc – xhg Mar 19 '17 at 19:31
  • @aahung zsh and bash languages differ .bashrc might cause syntax erros - much better to keep them separate – user151019 Mar 19 '17 at 20:19
  • You made a point. It was long time ago I did this when I was not familiar and chased convenience. And recently I notice when I installed a new version of Python, the installer append to bash-files instead of zsh-files. Maybe he/she has the similar situation – xhg Mar 19 '17 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .