J’écris le code suivant dans le carnet Jupyter.
import tensorflow as tf g = tf.Graph()
Et je rencontre l’erreur suivante lors de l’exécution de ce code simple.
AtsortingbuteError: le module ‘tensorflow’ n’a pas d’atsortingbut ‘Graph’
Si j’exécute le même depuis la console. Ça marche. Toute idée de ce qui se passe ici.
Plus d’informations: (test est mon virtualenv)
ipython, jupyter, version python:
(test) xingzhou@xingzhou008:~/tensorflow$ which ipython3 /home/xingzhou/tensorflow/test/bin/ipython3 (test) xingzhou@xingzhou008:~/tensorflow$ which jupyter /home/xingzhou/tensorflow/test/bin/jupyter (test) xingzhou@xingzhou008:~/tensorflow$ which python3 /home/xingzhou/tensorflow/test/bin/python3
Exécuter depuis la console:
(test) xingzhou@xingzhou008:~/tensorflow$ python3 Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> g = tf.Graph() >>> type(g) >>>
J’ai résolu ce problème en redémarrant le kernel Jupyter Notebook. C’est étrange.
Une solution simple a fonctionné pour moi. Du anaconda navigator
allez d’abord dans les environnements et créez un environnement tensorflow comme cette image
Je l’ai nommé tensorflow
. Ensuite, sélectionnez tout dans le menu déroulant et recherchez tensorflow.
Sélectionnez-le et appuyez sur Appliquer. Il téléchargera des paquets supplémentaires avec tensorflow. Lorsque vous avez terminé, sélectionnez tensorflow de chez vous et vous devriez être prêt à partir. Ici ça marche.
Assurez-vous de n’avoir appelé aucun de vos fichiers python en tant que ‘tensorflow.py’