【tensorflow】安装和卸载

基于 virtualenv 安装

  • 安装:

    1. 打开终端(a shell);
    2. 安装 pip(如果之前没有安装的话) 和 virtualenv :

          $ sudo easy_install pip
          $ sudo pip install --upgrade virtualenv
    3. 建立一个新的 virtualenv 环境 :

          $ virtualenv --system-site-packages ~/tensorflow
    4. 激活 virtualenv :

          $ cd ~/tensorflow
          $ source bin/activate # 如果使用 bash, sh, ksh, 或者 zsh
          $ source bin/activate.csh # 如果使用 csh 或者 tcsh
          终端发生变化:
          (tensorflow)$
    5. 安装 tensorflow :

          pip install --upgrade tensorflow # for python 2.7
          pip3 install --upgrade tensorflow # for python 3.n
    6. 测试是否安装成功 :

          (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!' # 安装成功
  • 卸载

    1. 执行卸载很简单,直接删除目录即可:
          rm -r ~/tensorflow

使用原生 pip 安装

  • 安装

    pip install tensorflow # python2.x
    pip3 install tensorflow # python3.x
  • 卸载

    pip uninstall tensorflow # python2.x
    pip3 uninstall tensorflow # python3.x

猜你喜欢

转载自blog.csdn.net/lionel_fengj/article/details/80484243