anaconda环境中---py2.7下安装tf1.0 + py3.5下安装tf1.5

anaconda环境中---py2.7下安装tf1.0 + py3.5下安装tf1.5

@wp20181030

  环境:ubuntu18.04, anaconda2, ubuntu系统下事先安装了python2.7.15(默认)和python3.6.5, .....

  这里,利用anaconda 2(自行先安装好),在建立py2.7 和 py3.5的环境分别安装tf1.0 和 tf1.5,具体的如下:

情况一:py2.7下安装tf1.0

#(1)新建一个test_py2环境【py2+tf1.0】
conda create -n <环境名,如test_py2> python==2.7
#(2)激活test_py2环境,以便后续使用
source activate test_py2
#安装tf
pip install --upgrade-installed tensorflow==1.0
#验证tf是否安装成功
$ python
>>> import tensorflow as tf
>>> tf.__version__

>>> tf.__path__
#卸载tf
pip uninstall tensorflow
#(3)退出test_py2环境
source deactivate test_py2
#(4)如果需要,卸载test_py2环境
conda remove -n test_py2 --all

情况二:py3.5下安装tf1.5
#(1)新建一个test_py3环境【py3+tf1.5】
conda create -n <环境名,如test_py2> python==3.5
#(2)激活环境,以便后续使用
source activate test_py3
#安装tf
pip install --ignore-installed --upgrade tensorflow-1.5.0-cp35-cp35m-manylinux1_x86_64.whl #官网上手动下载,tf与py要匹配https://pypi.org/project/tensorflow/1.5.0/#files  #下载的TensorFlow对应的Python版本一定要和conda create -n tensorflow python=x.x的版本一样才行
#验证tf是否安装成功
$ python
>>> import tensorflow as tf
>>> tf.__version__
#卸载tf
pip uninstall tensorflow
#(3)退出环境
source deactivate test_py3
#(4)如果需要,卸载环境
conda remove -n test_py3 --all


原文地址:https://www.cnblogs.com/carle-09/p/9875255.html