tensorflow - 导入张量流库错误
问题描述
调试后发现下面奇怪的错误
程序:(仅1行)import tensorflow as tf
当我第一次运行上述代码时,我收到以下警告: \AppData\Local\Continuum\anaconda3\lib\site-packages\h5py__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from float
to np.floating
is deprecated。将来,它将被视为np.float64 == np.dtype(float).type
. 从 ._conv 导入 register_converters 作为 _register_converters
=>来自网络,这只是一个警告,可以忽略它(我猜)
当我重新运行相同的代码时,出现以下错误
文件“C:\Users\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py”,第 710 行,运行文件 execfile(文件名,命名空间)
文件“C:\Users\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py”,第 101 行,在 execfile exec(compile(f.read(), filename, ' exec'), 命名空间)
文件“H:/Python/Test/Test.py”,第 15 行,在 import tensorflow as tf 中
文件“C:\Users\AppData\Roaming\Python\Python36\site-packages\tensorflow__init__.py”,第 24 行,在 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
文件“C:\Users\AppData\Roaming\Python\Python36\site-packages\tensorflow\python__init__.py”,第 121 行,来自 tensorflow.python.platform 导入测试
文件“C:\Users\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\platform\test.py”,第 65 行,在 tf_export('test.mock')(mock)
文件“C:\Users\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\util\tf_export.py”,第 96 行,调用中 (undecorated_func.name , undecorated_func._tf_api_names))
SymbolAlreadyExposedError:符号 unittest.mock 已公开为 ('test.mock',)。
现在我需要重新启动内核才能运行整个源代码。任何想法 ?
谢谢
解决方案
我尝试了这种方式并且它起作用了(进一步执行不需要更多的内核重启):
test.py
1/从此链接打开文件:
“C:\Users\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\platform\test.py”
2/ 注释第 65 行:#tf_export('test.mock')(mock)
推荐阅读
- r - 如何用dendextend标记层次聚类树中的一个观察?
- python - 无法从 ArcGIS REST API 获取形状数据
- angular - Angular 8 .htaccess 允许直接访问子文件夹
- java - Forge Mod Development 需要手动导入
- sql - 如何从包含行数据的列标题中提取月份中的某一天?
- angular - 刷新页面时无法收集 - AngularFire
- python - AttributeError:将我的模型连接到管理员时,“列表”对象没有属性“全部”
- scala - 自定义生成的 Slick SQL 以进行调试
- mosquitto - MQTT.fx TSLv1.3 SSLContext 不可用
- tableau-api - Tableau - 创建重叠的日期箱