2017-02-15 158 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,並且錯誤消失。

相關問題