【发布时间】: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。