【问题标题】:Anaconda installation modifying .bash_profile on Mac OS X在 Mac OS X 上修改 .bash_profile 的 Anaconda 安装
【发布时间】:2019-10-21 15:39:16
【问题描述】:

我在我的 Mac (Mojave) 上安装了 Anaconda,现在每当我启动 shell 时,它都会自动激活 conda 环境。这完全没问题,直到我意识到我的 .bashrc 中的一些命令在启动时没有被执行。特别是,我增加了 HISTSIZE 和 HISTFILESIZE ,但它们似乎总是停留在默认值 500 上。经过一番谷歌搜索后,我了解到由于我的 anaconda 安装,在启动时使用的是我的 .bash_profile 而不是 .bash_profile。 .bashrc。这就是我的 .bash_profile 的样子(见下文),只是将我的 .bashrc 文件中的命令(例如,HISTFILESIZE=100000)添加到我的 .bash_profile 顶部似乎什么都不做。关于我做错了什么的任何建议?谢谢!

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# added by Anaconda3 2019.07 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"  # commented out by conda initialize
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('//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"
    else
        export PATH="//anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

【问题讨论】:

    标签: bash macos anaconda conda


    【解决方案1】:

    您可以尝试按照Here 的建议在 bash_profile 中添加以下行:

    if [ -f ~/.bashrc ]; then
        source ~/.bashrc
    fi
    

    【讨论】:

      猜你喜欢
      • 2018-02-01
      • 2016-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-28
      • 2017-01-16
      • 2013-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多