安装成功后无法导入Tensorflow



Tensorflow已成功安装在Conda环境中,但是我无法导入Tensorflow。我也使用代码:conda update numpy更新了numpy。我得到以下错误的代码:

import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-15-64156d691fe5>", line 1, in <module>
import tensorflow as tf
File "C:Userstanaconda3libsite-packagestensorflow__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:Userstanaconda3libsite-packagestensorflowpython__init__.py", line 45, in <module>
from tensorflow.python import data
File "C:Userstanaconda3libsite-packagestensorflowpythondata__init__.py", line 25, in <module>
from tensorflow.python.data import experimental
File "C:Userstanaconda3libsite-packagestensorflowpythondataexperimental__init__.py", line 96, in <module>
from tensorflow.python.data.experimental import service
File "C:Userstanaconda3libsite-packagestensorflowpythondataexperimentalservice__init__.py", line 21, in <module>
from tensorflow.python.data.experimental.ops.data_service_ops import distribute
File "C:Userstanaconda3libsite-packagestensorflowpythondataexperimentalopsdata_service_ops.py", line 25, in <module>
from tensorflow.python.data.experimental.ops import compression_ops
File "C:Userstanaconda3libsite-packagestensorflowpythondataexperimentalopscompression_ops.py", line 20, in <module>
from tensorflow.python.data.util import structure
File "C:Userstanaconda3libsite-packagestensorflowpythondatautilstructure.py", line 33, in <module>
from tensorflow.python.ops import tensor_array_ops
File "C:Userstanaconda3libsite-packagestensorflowpythonopstensor_array_ops.py", line 38, in <module>
from tensorflow.python.ops import array_ops
File "C:Userstanaconda3libsite-packagestensorflowpythonopsarray_ops.py", line 1475, in <module>
_NON_AUTOPACKABLE_TYPES = set(np.core.numerictypes.ScalarType)
AttributeError: module 'numpy.core' has no attribute 'numerictypes'

为tensorflow创建一个新环境,并使用下面的代码重新安装tensorflow:

conda create -n tf tensorflow python=3.5
conda activate tf
conda install pip
pip install tensorflow

然后重试执行您的代码。如果问题仍然存在,请告诉我们。

相关内容

  • 没有找到相关文章

最新更新