在修改.bash_profile以便在macOS Catalina上安装Tensorflow + OpenCV时,为什么会出现这些语法错误?

时间:2020-03-30 17:24:20

标签: bash macos tensorflow terminal anaconda

我正在尝试在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

谢谢!

1 个答案:

答案 0 :(得分:0)

正如@Cromax在我的问题帖子下方的评论中所指定的那样,我忘记了在第四行中用双引号引起来。

相关问题