首页 > 解决方案 > 为什么我在修改 .bash_profile 以在 macOS Catalina 上安装 Tensorflow + OpenCV 时出现这些语法错误?

问题描述

我正在尝试在 Jupyter Notebook(Python 3.7,macOS Catalina)上创建一个深度学习环境,并将 Tensorflow 和 OpenCV 放在上面。我正在遵循以下网站上的说明:https ://mc.ai/deep-learning-on-macos-catalina/ 。我在步骤“将以下内容添加到 .bash_profile 文件...”。我刚刚做了(不确定我什么时候打算将“export PS1”中的部分添加到“/virtualenvwrapper.sh”,所以我只是随意地把它放在那里)它看起来像这样(在我使用 nano 查看它之后.bash_profile)。

export PS1="___________________    | \w @ \h (\u) \n| => "
export PS2="| =>
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

但是,我收到两个错误:

-bash: .bash_profile: line 16: unexpected EOF while looking for matching `"'
-bash: .bash_profile: line 21: syntax error: unexpected end of file 

为了继续下一步,我需要做些什么来解决这些问题?

否则,有没有更简单的方法可以在同一环境中同时使用 Tensorflow 和 OpenCV 而无需经历所有这些?(知道我已经有 Anaconda Python 3.7)

非常感谢 !

更新:我在这里和那里尝试了一些东西,我的新 .bash_profile 现在看起来像这样:

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

export PS1="___________________    | \w @ \h (\u) \n| => "
export PS2="| =>

alias ll='ls -FGlAhp'

export PATH=/usr/local/bin:$PATH

 >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

但是我现在终端窗口有问题,我不知道如何处理它。

我实际上有同样的错误:

-bash: .bash_profile: line 19: unexpected EOF while looking for matching `"'
-bash: .bash_profile: line 24: syntax error: unexpected end of file

提前致谢!

标签: bashmacostensorflowterminalanaconda

解决方案


正如@Cromax 在我的问题帖子下的评论中指定的那样,我忘记关闭第 4 行中的双引号。


推荐阅读