2.TensorFlow简要教程系列(一)Mac安装TensorFlow
按照官方的方法走,我发现,第一步我就走不下去。我是MacOS系统,第一步是安装pip。
命令是:sudo easy_install pip
结果是卡在那,一个晚上都没结果,下面是截图:
然后各种搜索,换了一种方式:
1.
如果没有wget, 那么brew install wget
2.用wget下载
wget https://bootstrap.pypa.io/get-pip.py
3.安装
sudo python get-pip.py
4.(pip在第3步已经安装好,开始官方的第二步,安装virtualenv)
sudo pip install --upgrade virtualenv
5. 创建一个virtualenv环境(下面有两个命令,选一个,第一个是为Python 2.7创建的环境,第二个是为Python 3.n):
virtualenv --system-site-packages targetDirectory # for Python 2.7
virtualenv --system-site-packages -p python3 targetDirectory # for Python 3.n
拷贝第5步命令,下面是执行结果:
New python executable in /Users/用户/targetDirectory/bin/python
6.安装tensorflow:
pip install tensorflow
7.激活virtualenv环境通过x下面两条命令任意一个,#号后面是对这个命令的说明,一般是第一个
source ~/tensorflow/bin/activate # If using bash, sh, ksh, or zsh
source ~/tensorflow/bin/activate.csh # If using csh or tcsh
第二种方式:直接使用anaconda
从这里下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
下载慢?配个清华的镜像源,
终端输入:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
tensorflow链接:https://mirrors.tuna.tsinghua.edu.cn/tensorflow/mac/cpu/
比如要安装1.4版本的,找到对应的版本,在终端conda目录下输入((/Users/用户名/anaconda/envs/tensorflow15)):
国内源:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ https://mirrors.tuna.tsinghua.edu.cn/tensorflow/mac/cpu/tensorflow-1.4.0-py3-none-any.whl
官方源:
sudo pip3 install --upgrade \ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.6.0-py3-none-any.whl
pip install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.6.0-py3-none-any.whl