gpt4 book ai didi

python - 导入keras时出错 ModuleNotFoundError : No module named 'tensorflow.examples' ; 'tensorflow' is not a package

转载 作者:行者123 更新时间:2023-12-01 08:53:55 65 4
gpt4 key购买 nike

我尝试导入 keras 但它说:

import keras Using TensorFlow backend. Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/keras/init.py", line 3, in from . import utils File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/keras/utils/init.py", line 6, in from . import conv_utils File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/keras/utils/conv_utils.py", line 9, in from .. import backend as K File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/keras/backend/init.py", line 89, in from .tensorflow_backend import * File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/keras/backend/tensorflow_backend.py", line 5, in import tensorflow as tf File "/Users/elanchezhian/tensorflow.py", line 2, in from tensorflow.examples.tutorials.mnist import input_data ModuleNotFoundError: No module named 'tensorflow.examples'; 'tensorflow' is not a package

我使用的是 mac os high Sierra,我在 python3 中运行 keras,并且我使用 pip 安装了 keras

编辑:好的,我已经有一个名为tensorflow.py的文件,我删除了它,然后出现了新错误

回溯(最近一次调用最后一次): 文件“”,第 1 行,位于 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/init.py”,第 3 行,位于 从 。导入实用程序 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/init.py”,第 6 行,位于 从 。导入 conv_utils 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/conv_utils.py”,第 9 行,位于 from .. 将后端导入为 K 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/backend/init.py”,第 89 行,位于 从 .tensorflow_backend 导入 * 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py”,第 5 行,位于 将 tensorflow 导入为 tfImportError:“tensorflow”中的错误魔数(Magic Number):b'\x03\xf3\r\n'

编辑:我已经删除了tensorflow.pyc,现在出现了这个错误:

RuntimeError: module compiled against API version 0xc but this version 
of
numpy is 0xb
ImportError: numpy.core.multiarray failed to import
ImportError: numpy.core.umath failed to import
ImportError: numpy.core.umath failed to import
2018-10-21 10:53:26.723451: F
tensorflow/python/lib/core/bfloat16.cc:675]
Check failed: PyBfloat16_Type.tp_base != nullptr
Abort trap: 6

最佳答案

您的脚本名为tensorflow.py,与真实的tensorflow包的名称冲突。将您的脚本命名为其他名称。

关于python - 导入keras时出错 ModuleNotFoundError : No module named 'tensorflow.examples' ; 'tensorflow' is not a package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52909618/

65 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com