为什么我的默认 PATH 中有一些 /Library/Frameworks/Python.framework/Versions/X.X/bin?
Why do I have some /Library/Frameworks/Python.framework/Versions/X.X/bin in my default PATH?
我最近从我的笔记本电脑 (MacOS Catalina) 上卸载了所有 python 版本。它们是通过 python.org 的 .pkg
文件直接安装的,这里没有 Homebrew。
我正在使用 ZSH,我的 ~/.zshrc
不包含任何将 Python 添加到 $PATH 的东西。
我的 ~/.profile
包含以下内容:
export PATH="$PATH:$HOME/.rvm/bin:$HOME/.node/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="$HOME/.cargo/bin:$PATH"
我的 /etc/profile
包含:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
文件 /etc/paths
包含以下内容:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
最后,我在 /etc/paths.d
目录中有这个:
~ ls /etc/paths.d
git
现在,当我在我的终端中 运行 echo $PATH
时,这是我所拥有的:
~ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/Adrien/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
这些 Python 路径来自哪里?
有没有我遗漏的 .plist 文件?
当我切换到 bash 时得到相同的结果。
详述 here,当 ZSH 启动时,它会以特定顺序获取许多文件,其中一些影响 PATH
变量。
就我而言,~/.zprofile
包含以下内容(可能是在 Python 安装期间设置的):
# Setting PATH for Python 3.7
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
作为参考,这里是 ZSH 评估的文件列表,按评估顺序排列:
/etc/zshenv
~/.zshenv
/etc/zprofile
~/.zprofile
/etc/zshrc
~/.zshrc
/etc/zlogin
~/.zlogin
~/.zlogout
/etc/zlogout
我最近从我的笔记本电脑 (MacOS Catalina) 上卸载了所有 python 版本。它们是通过 python.org 的 .pkg
文件直接安装的,这里没有 Homebrew。
我正在使用 ZSH,我的 ~/.zshrc
不包含任何将 Python 添加到 $PATH 的东西。
我的 ~/.profile
包含以下内容:
export PATH="$PATH:$HOME/.rvm/bin:$HOME/.node/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="$HOME/.cargo/bin:$PATH"
我的 /etc/profile
包含:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
文件 /etc/paths
包含以下内容:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
最后,我在 /etc/paths.d
目录中有这个:
~ ls /etc/paths.d
git
现在,当我在我的终端中 运行 echo $PATH
时,这是我所拥有的:
~ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/Adrien/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
这些 Python 路径来自哪里? 有没有我遗漏的 .plist 文件?
当我切换到 bash 时得到相同的结果。
详述 here,当 ZSH 启动时,它会以特定顺序获取许多文件,其中一些影响 PATH
变量。
就我而言,~/.zprofile
包含以下内容(可能是在 Python 安装期间设置的):
# Setting PATH for Python 3.7
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
作为参考,这里是 ZSH 评估的文件列表,按评估顺序排列:
/etc/zshenv
~/.zshenv
/etc/zprofile
~/.zprofile
/etc/zshrc
~/.zshrc
/etc/zlogin
~/.zlogin
~/.zlogout
/etc/zlogout