1.确认环境:macos sierra 10.12.6,新建目录:~/tf-course
2.检查工具集:python --version,pip --version,brew update
3.安装pip:
~/tf-course% curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
~/tf-course% sudo python get-pip.py
4.使用pip安装 virtualenv
~/tf-course% sudo pip install -u virtualenv
~/tf-course% virtualenv --version 16.2.0
5.搭建虚拟环境
~/tf-course% sudo virtualenv --system-site-packages -p python2.7 ./venv
激活venv环境:
~/tf-course% source venv/bin/activate
6.使用pip安装tensorflow
(venv) localhost% pip install tensorflow
7.查看是否安装成功
(venv) localhost% pip list installed 可以查看到安装成功tensorflow 1.12.0 版本
进入python交互式环境查看:
(venv) localhost% python
>>> import tensorflow as tf
>>>exit()
8.离开virtualenv环境
(venv) localhost% deactivate
网友评论