【问题标题】:$PATH not being set in .bash_profile$PATH 未在 .bash_profile 中设置
【发布时间】:2020-08-18 05:22:05
【问题描述】:

我使用的是 MACOS Catalina 10.15.4。我正在尝试在 ~/.bash_profile 中设置 PATH 变量。

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.7/bin"
export PATH="$PATH:/Users/some_user/Desktop/path_to_some_folder/bin"
# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

但是,当我在终端上回显 $PATH 时,我得到以下信息:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

我检查了我的路径仅是从 /etc/paths 和 /etc/paths.d 设置的。 如何确保 PATH 也是从 .bash_profile 文件中设置的?

另外,我的主目录中有 .bash_profile-anaconda3.bak、.bash_sessions 和 .bash_history,如果有什么不同的话。

编辑:我尝试在 .bashrc 中导出 PATH,但这也不起作用。

【问题讨论】:

  • 如果这是一个新帐户,您运行的不是bash,而是zsh。你应该改用.zprofile

标签: bash macos path


【解决方案1】:

正如@chepner 所建议的,因为 macOS 上的所有新帐户现在都使用 zsh。我使用 .zprofile 重新配置了我的路径。

【讨论】:

    猜你喜欢
    • 2016-11-04
    • 2013-07-27
    • 2013-02-13
    • 2013-10-14
    • 2013-04-23
    • 2017-01-17
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多