bash - echo $PATH 显示一个 Python.Framework 目录。重新启动终端后更改被撤销
问题描述
所以我跑了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 的路径。请帮助我,这很令人沮丧。
解决方案
您应该放入PATH
而~/.bashrc
不是~/.bash_profile
.
因为~/.bash_profile
仅当 bash 作为登录 shell 调用时才会生效,这意味着您应该重新登录或使用该--login
选项运行 bash。
~/.bashrc
,相反,将在启动交互式 shell 时读取并执行。这在您重新启动终端时有效。
编辑:对不起,我发现你的外壳是 zsh。上面的答案是针对 bash 的。
对于 zsh,PATH
放入$ZDOTDIR/.zshrc
.
然后从 读取命令
$ZDOTDIR/.zshenv
。如果 shell 是登录 shell,则从 读取命令/etc/zsh/zprofile
,然后$ZDOTDIR/.zprofile
.然后,如果 shell 是交互式的,则从 读取命令
/etc/zsh/zshrc
,然后$ZDOTDIR/.zshrc
.最后,如果shell是一个登录shell,
/etc/zsh/zlogin
并且$ZDOTDIR/.zlogin
被读取。
如果您不设置ZDOTDIR
变量,则这些文件位于您的主目录中。
推荐阅读
- python - 如何知道本地安装在设备中的 Torch 版本
- mysql - 垂直连接 MySQL 表,插入 NULL
- python - 如何确定两个列表在 python 中是否具有相同的属性?
- reactjs - React Hook useCallback 缺少依赖项:
- python - 熊猫堆积条创建许多具有不正确底部值的单独图
- typescript - 如何在打字稿中获取泛型类型的参数
- macos - 如何使用脚本安装 mac os 应用程序?
- arrays - C中文件范围错误的可变修改“数据”
- swiftui - 为什么这个 SwiftUI LazyHStack 不断更新?
- c - 如何在 C 中使用指针时实现 Scanf