2017-02-15 159 views
4

请帮我这个错误导入错误:没有tensorflow命名模块

我已经安装在服务器上的tensorflow模块下面是它的信息

[email protected]:~$ pip show tensorflow 
Name: tensorflow 
Version: 1.0.0 
Summary: TensorFlow helps the tensors flow 
Home-page: http://tensorflow.org/ 
Author: Google Inc. 
Author-email: [email protected] 
License: Apache 2.0 
Location: /home/other/15IT60R19/anaconda2/lib/python2.7/site-packages 
Requires: mock, numpy, protobuf, wheel, six 

但是,当我尝试导入tensorflow我获得以下错误

>>> import tensorflow as tf 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named tensorflow 

我的Python版本如下所示:

Python 2.7.12 |Anaconda 2.5.0 (64-bit)| (default, Jul 2 2016, 17:42:40) 
[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 

我曾尝试在 sol1

Sol2

给出的解决方案,我没有对服务器 sudo访问我只能用PIP安装任何模块

回答

0

我正试图安装张力流GPU的Windows 7与pip3 python3.5.x。 而不是做pip3 install --upgrade tensorflow我刚刚做了pip install tensorflow并且在它完成后我终于能够在python3.5.x中导入tensorflow了。

4

检查Tensorflow已成功安装使用:

pip3 show tensorflow 

如果你喜欢的东西

Name: tensorflow 
Version: 1.2.1 
Summary: TensorFlow helps the tensors flow 
Home-page: http://tensorflow.org/ 
Author: Google Inc. 
Author-email: [email protected] 
License: Apache 2.0 
Location: /usr/local/lib/python3.5/dist-packages 
Requires: bleach, markdown, html5lib, backports.weakref, werkzeug, numpy, protobuf, wheel, six 

您可以尝试通过添加tensorflow位置的路径:

export PYTHONPATH=/your/tensorflow/path:$PYTHONPATH. 
+0

也pip显示tensorflow – YaBoiSandeep

7

尝试再次使用您想要的任何版本安装tensorflow,并使用选项--ignore-inst alled like:

pip install tensorflow==1.2.0 --ignore-installed 

我使用此命令解决了同样的问题。

0

尝试在用户站点安装tensorflow - 此安装只适用于您。

pip install tensorflow --user

6

对于Anaconda3,只需安装在蟒蛇导航: enter image description here

+0

tensorflow的安装与Anaconda Navigator完美配合。 –

0

通过发出以下命令之一激活的virtualenv环境:

$源〜/ tensorflow /斌/启动#庆典, SH,ksh或zsh的
$源〜/ tensorflow /斌/ activate.csh#csh或tcsh

希望这有助于

0

这个工作对我来说:

$ sudo easy_install pip 
$ sudo easy_install --upgrade six 
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl 
$ sudo pip install --upgrade $TF_BINARY_URL 
1

我有一个更基本的问题,当我收到此错误。

“验证安装”说明书说键入:蟒蛇

不过,我安装了2.7和3.6。因为我以前PIP3安装tensorflow,我需要键入:python3

使用正确的版本,我可以导入“tensorflow”模块。

1

而不是使用doc的命令(conda create -n tensorflow pip python=2.7 # or python=3.3, etc.),它想要在conda环境中安装python2.7,并且在执行安装验证步骤时错误地指出找不到模块,我使用conda create -n tensorflow pip python=3来确保python3安装在环境中。

这样做时,我只需在验证安装时输入python而不是python3,并且错误消失。

相关问题