在Ubuntu 16.04上安装Tensorflow

3
我曾试过在Ubuntu 16.04上安装Tensorflow,但是…
Collecting tensorflow==0.7.1 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
  Using cached https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
Requirement already up-to-date: numpy>=1.8.2 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python2.7/dist-packages (from tensCollecting tensorflow==0.7.1 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
  Using cached https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
Requirement already up-to-date: numpy>=1.8.2 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: protobuf==3.0.0b2 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: wheel in /usr/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/dist-packages (from protobuf==3.0.0b2->tensorflow==0.7.1)
Installing collected packages: tensorflow
  Found existing installation: tensorflow 0.7.1
    Uninstalling tensorflow-0.7.1:
      Successfully uninstalled tensorflow-0.7.1
Successfully installed tensorflow-0.7.1
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
milenko@milenko-HP-Compaq-6830s:~$ python
Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:08:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
orflow==0.7.1)

我使用了sudo -H命令,因此我不明白为什么会出现这种情况。 我的Python安装。
readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V'
/home/milenko/miniconda2/bin/python2.7: Python 2.7.11 :: Continuum Analytics, Inc.

你可能安装了不止一个Python版本--默认版本和Anaconda版本,尝试使用/usr/bin/python或者/usr/local/bin/python而不是直接使用python - Yaroslav Bulatov
@YaroslavBulatov 是的,我已经安装了Miniconda。 - Richard Rublev
所以我猜其中一个在sys.path中有/usr/local/lib/python2.7/dist-packages,而另一个没有,因此另一个看不到tensorflow - Yaroslav Bulatov
@YaroslavBulatov bash:cd:/usr/local/bin/python:没有那个文件或目录 - Richard Rublev
Anaconda使用自己的路径来存储软件包,因此在Anaconda上安装TensorFlow略有不同。关于此问题,在“[tensorflow] anaconda”上已经有了一些解答。 - Yaroslav Bulatov
1个回答

1

这个教程对我很有用。

我使用的是Anaconda 2.7版本,并创建了一个虚拟环境(如果需要可以使用py3和python=3.5):

conda create --name py2 python=2.7 anaconda

在安装之前(以及之后使用!)不要忘记激活它:

source activate py2

我建议升级scikit-learn和libgcc:

conda upgrade scikit-learn libgcc

接着按照链接的教程进行操作。

我认为自从你5个月前提问以来,情况已经发生了很大变化,但我希望这篇文章能够帮助到那些偶然看到这篇文章的人。在你的情况下,我想这确实是miniconda和系统python分发之间的冲突。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接