所以我跑了brew doctor
,结果就出来了:
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
然后,当我键入export PATH=/usr/bin:/bin:/usr/sbin:/sbin
并回显$ PATH时,它会给我export PATH=/usr/bin:/bin:/usr/sbin:/sbin
但是,当我重新启动终端(iTerm2 zsh)时,它会返回到/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
此$ PATH看起来不正确。我对$ PATH不太了解,但是有办法将其修复为应有的状态吗?我还尝试编辑.bash_profile
并放置PATH=/usr/bin:/bin:/usr/sbin:/sbin
路径而不是python路径-当我回显$ PATH时,仍然没有运气,它仍然是python路径。请帮助我,这令人沮丧。
答案 0 :(得分:0)
您应该将PATH
放入~/.bashrc
而不是~/.bash_profile
。
因为~/.bash_profile
仅在bash作为登录shell调用时有效,这意味着您应该使用--login
选项重新登录或运行bash。
~/.bashrc
。当您重新启动终端时,此方法有效。
编辑:对不起,我发现您的shell是zsh。上面的答案是针对bash的。
对于zsh,将PATH
放入$ZDOTDIR/.zshrc
。
然后从
$ZDOTDIR/.zshenv
中读取命令。如果该外壳程序是登录外壳程序,则从/etc/zsh/zprofile
读取命令,然后从$ZDOTDIR/.zprofile
读取命令。然后,如果外壳是交互式的,则从
/etc/zsh/zshrc
读取命令,然后从$ZDOTDIR/.zshrc
读取命令。最后,如果该外壳程序是登录外壳程序,则将读取
/etc/zsh/zlogin
和$ZDOTDIR/.zlogin
。
如果您未设置ZDOTDIR
变量,则这些文件位于您的主目录中。
答案 1 :(得分:0)
代替围绕Bash / Zsh&co的各种问题,以及相应的~/.bashrc
,~/.zshrc
等;如果您有足够的访问权限,则可以考虑在/etc/profile.d
目录下的专用文件中定义PATH变量。
例如:
sudo cat > /etc/profile.d/variousEnvironmentUpdates.sh <<EOF
PATH=<what you want first>:$PATH
EOF