【发布时间】:2020-07-25 19:35:51
【问题描述】:
我最近从我的笔记本电脑 (MacOS Catalina) 上卸载了所有 python 版本。它们是通过来自 python.org 的 de .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 时,我得到了相同的结果。
【问题讨论】:
-
关于配置编程相关工具的问题更适合Super User。这个特定问题也将成为Unix & Linux 的主题。但我认为这不是主题
-
您的
~/.bash_profile中有什么内容? -
这是我在
~/.bash_profile中的内容:[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 -
也许你的 ~/.zshrc 中的某些东西间接添加了 python 路径?你能展示你的 ~/.zshrc 吗?
-
我终于在这个非常详细的答案中找到了答案:unix.stackexchange.com/a/250456 在我的例子中,python 安装更新了由 zsh 提供的
~/.zprofile文件。
标签: python macos path environment-variables zsh