我正在尝试开始学习Tensorflow,但是遇到了一个错误。
我在谷歌和这个网站上搜索,但没有找到答案。
让我解释一下。我当前正在使用我的计算机上的anaconda3。我使用'Anaconda Prompt'通过 pip install -q --upgrade tensorflow
安装了tensorflow。
它可以工作,但是当我运行这段代码(来自这里)时:
from __future__ import absolute_import, division, print_function
import os
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow.contrib.eager as tfe
tf.enable_eager_execution()
print("TensorFlow version: {}".format(tf.VERSION))
print("Eager execution : {}".format(tf.executing_eagerly()))
I get the following error:
Traceback (most recent call last):
File "<ipython-input-11-9a561e7b074b>", line 1, in <module>
runfile('C:/Users/emile/Desktop/tensorflow.py', wdir='C:/Users/emile/Desktop')
File "C:\Users\emile\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\emile\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/emile/Desktop/tensorflow.py", line 6, in <module>
import tensorflow as tf
File "C:\Users\emile\Desktop\tensorflow.py", line 7, in <module>
import tensorflow.contrib.eager as tfe
ModuleNotFoundError: No module named 'tensorflow.contrib'; 'tensorflow' is not a package
也许问题是由Anaconda引起的吗?
非常感谢。