对于自制软件,我应该在 bash_profile 中放置什么路径?

What paths should I place in the bash_profile for homebrew?

我正在尝试设置自制软件,以便使用 Python,但我的 PATH 遇到了一些问题,我尝试了不同的版本。我的 bash_profile 有点乱,我想将它编辑回干净的版本,或者干净到可以使用自制软件。我以前用过蟒蛇。

当前有以下文字

# >>> 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 <<<

# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
export PATH=/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
export PATH=“/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin”’
export PATH="/usr/local/bin:$PATH"
export PATH=‚Äô/usr/local/bin:Äô
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/local/bin"
export PATH="/usr/local/bin:$PATH"
export PATH=“/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin”’
export PATH="/usr/local/bin:$PATH"

我应该怎么做才能让它恢复到原来的状态?

如果您阅读上面新版本的评论,您将看到以下行:

# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave

我可能会这样做:

diff .bash_profile.pysave .bash_profile

找出不同之处并适当编辑。我不使用 conda,但看起来您可能只想删除以下行:

# >>> conda init >>>

# <<< conda init <<<

最后,我会在进行上述调整后退出 bash,重新启动终端,然后阅读此处了解如何安装 Python 的详细信息:https://docs.brew.sh/Homebrew-and-Python


你可以全部删除。如果您根本不对 PATH 执行任何操作,您将从 /usr/libexec/path_helper/etc/profile 设置的值开始,其中包括旧文件明确设置的所有内容。

您可以从命令行运行 /usr/libexec/path_helper查看它添加了什么;它只会将一些 shell 命令打印到标准输出,而不会实际执行这些命令。默认 /etc/profile 执行这些命令。