1.安装brew,在终端中输入:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
注意:如果当前的用户是管理员,需要对权限进行许可,在执行上面的指令前先执行:sudo chmod -R g+w /usr/local
2.安装python 3
brew install python3
3.安装virtualenv、virtualenvwrapper
pip3 install virtualenv
pip3 install virtualenvwrapper
4.创建一个文件夹,用于存放虚拟环境
mkdir ~/pyEnv
5.在使用virtualenvwrapper之前,要运行virtualenvwrapper.sh文件,需要设置环境变量
vim进入~/.bash_profile,插入
export WORKON_HOME=~/pyEnv source /usr/local/bin/virtualenvwrapper.sh
命令行中运行以上
若提示
If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.
在bash_profile中 加入
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
1
mkvirtualenv、workon命令即可使用
6.source ~/pyEnv/bin/activate
7.安装tensorflow
pip3 install --upgrade tensorflow