基於 virtualenv 安裝
安裝:
- 打開終端(a shell);
安裝 pip(如果之前沒有安裝的話) 和 virtualenv :
$ sudo easy_install pip $ sudo pip install --upgrade virtualenv
建立一個新的 virtualenv 環境 :
$ virtualenv --system-site-packages ~/tensorflow
激活 virtualenv :
$ cd ~/tensorflow $ source bin/activate # 如果使用 bash, sh, ksh, 或者 zsh $ source bin/activate.csh # 如果使用 csh 或者 tcsh 終端發生變化: (tensorflow)$
安裝 tensorflow :
pip install --upgrade tensorflow # for python 2.7 pip3 install --upgrade tensorflow # for python 3.n
測試是否安裝成功 :
(tensorflow) $ bin python Python 3.5.2 (default, Jul 28 2016, 21:28:00) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello)) b'Hello, TensorFlow!' # 安裝成功
卸載
- 執行卸載很簡單,直接刪除目錄即可:
rm -r ~/tensorflow
- 執行卸載很簡單,直接刪除目錄即可:
使用原生 pip 安裝
安裝
pip install tensorflow # python2.x pip3 install tensorflow # python3.x
卸載
pip uninstall tensorflow # python2.x pip3 uninstall tensorflow # python3.x