2016-07-06 23 views
5

ho alcune importazioni nel mio quaderno jupyter e tra loro è tensorflow:No module named tensorflow in jupyter

ImportError        Traceback (most recent call last) 
<ipython-input-2-482704985f85> in <module>() 
     4 import numpy as np 
     5 import six.moves.copyreg as copyreg 
----> 6 import tensorflow as tf 
     7 from six.moves import cPickle as pickle 
     8 from six.moves import range 

ImportError: No module named tensorflow 

Ce l'ho sul mio computer, in un ambiente speciale e tutte le cose collegate anche:

Requirement already satisfied (use --upgrade to upgrade): tensorflow in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages 
Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) 
Requirement already satisfied (use --upgrade to upgrade): protobuf==3.0.0b2 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) 
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.10.1 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) 
Requirement already satisfied (use --upgrade to upgrade): wheel in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) 
Requirement already satisfied (use --upgrade to upgrade): setuptools in ./setuptools-23.0.0-py2.7.egg (from protobuf==3.0.0b2->tensorflow) 

posso importare tensorflow sul mio computer:

>>> import tensorflow as tf 
>>> 

Quindi sono confuso perché questo è un altro sit stai andando su un quaderno?

+2

Probabilmente problema di sys.path Scommetto che "jupyter" e "python" provengono da diverse installazioni Python, quindi hai installato tensorflow per uno, ma non l'altro –

+0

Si consiglia di installare un kernel ipython nel proprio ambiente speciale. – cel

+0

Possibile duplicato di [Nessun modulo denominato flusso tensoriale - taccuino iPython] (http://stackoverflow.com/questions/37756452/no-module-named-tensor-flow-ipython-notebook) –

risposta

13

Se è stato installato un tensorflow come si legge in documentazione ufficiale: https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#overview

intendo creare un ambiente chiamato tensorflow e testato l'installazione in Python, ma tensorflow non possono essere importati in jupyter, è necessario installare jupyter nel proprio ambiente tensorflow troppo:

conda install jupyter notebook 

Dopo che ho eseguito un jupyter e può importare tensorflow troppo:

jupyter notebook 
+1

Preferisco questa soluzione, poiché non richiede alcun giochetto manuale. Sembra che installando jupyter all'interno dell'ambiente, il jupyter "globale" venga oscurato e tutto sia impostato correttamente. (nota: ho dovuto avviare una nuova sessione della console dopo l'installazione) –

7

Ho avuto lo stesso problema e risolto, cercando in uscita:

jupyter kernelspec list

che emette le informazioni del kernel:

python2 /Users/Username/Library/Jupyter/kernels/python2 python3 /Users/Username/Library/Jupyter/kernels/python3

notare che i punti di percorso per la Kernel Jupyter per l'utente. Per utilizzarlo all'interno dell'ambiente Anaconda, è necessario puntare al messaggio che stai utilizzando e assomiglia a Anaconda3\envs\Env_Name\share\jupyter\kernels\python3.

Quindi, per rimuovere la Jupyter kernelspec, basta usare:

jupyter kernelspec remove python3

o jupyter kernelspec remove python2 se si sta utilizzando Python 2

Ora, l'uscita del jupyter kernelspec list deve puntare al kernel corretto.

Vedere https://github.com/jupyter/notebook/issues/397 per ulteriori informazioni a riguardo.

1

Questo è quello che ho fatto per risolvere questo problema -

ho installato tensorflow per Windows utilizzando il collegamento sotto -

https://www.tensorflow.org/install/install_windows

Una volta fatto - ho attivato tensorflow utilizzando sotto il comando -

C:> attiva tensorflow (tensorflow) C:> # La richiesta deve essere modificata

Una volta fatto mi sono imbattuto qui sotto comando -

(tensorflow) C:> Conda installare notebook

Recupero pacchetto di metadati ........... specifiche del pacchetto Solving:.

piano di pacchetto per l'installazione in ambiente

I seguenti pacchetti NUOVI saranno installati:

bleach:    1.5.0-py35_0 
colorama:   0.3.9-py35_0 
decorator:   4.1.2-py35_0 
entrypoints:   0.2.3-py35_0 
html5lib:   0.9999999-py35_0 
ipykernel:   4.6.1-py35_0 
---- 
--- 

jupyter_client 100% | ################# ############## | Tempo: 0:00:00 6,77 MB/s nbformat-4.4.0 100% | ######################################################## # | Tempo: 0:00:00 8.10 MB/s ipykernel-4.6. 100% | ############################### | Tempo: 0:00:00 9,54 MB/s nbconvert-5.2. 100% | ############################### | Tempo: 0:00:00 9.59 MB/s notebook-5.0.0 100% | ####################################### # | Tempo: 00:00:00 8.24 MB/s

Una volta fatto mi sono imbattuto comando

(tensorflow) C:> jupyter notebook

Si è aperta una nuova finestra Juypter e in grado di funzionare bene -

import tensorflow as tf

1

Sono stato in grado di caricare tensorflow nel notebook Jupyter su Windows: prima di tutto, creare l'installazione di tensorflow, quindi attivare tensorflow al prompt dei comandi, quindi eseguire "Jupyter notebook" dalla riga di comando. Tensorflow importa sul notebook senza errori. Tuttavia, non sono riuscito a importare "Pandas" & "Matplotlib, .... ecc"