【发布时间】:2022-12-25 15:30:00
【问题描述】:
我在导入时不断收到以下错误:
ImportError: cannot import name 'experimental_functions_run_eagerly' from 'tensorflow.python.eager.def_function'
我已经尝试使用 pip 卸载并重新安装 tensorflow。
在我尝试导入 tensorflow 时发生错误,但这里是所有错误:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import cv2
import tensorflow as tf
from tf import keras
我在 Windows 10 上运行 Python 3.7.9。由于错误,我无法导入 Tensorflow,但根据 pip list,这些是我的安装版本:
jupyter_client 7.4.7
jupyter_core 4.11.2
jupyter-server 1.23.2
jupyterlab 3.5.0
jupyterlab-pygments 0.2.2
jupyterlab_server 2.16.3
jupyterthemes 0.20.0
keras 2.11.0
tensorboard 2.11.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow 2.11.0
tensorflow-cpu 2.11.0
tensorflow-estimator 2.11.0
tensorflow-intel 2.11.0
tensorflow-io-gcs-filesystem 0.27.0
termcolor 2.1.0
我该如何解决这个错误?
【问题讨论】:
-
你能分享你正在尝试做的所有导入吗?另外,如果您只是尝试
import tensorflow as tf,它还会给您一个错误吗? -
当我尝试在相同的给定环境(Windows 10、jupyter notebook、python 3.7 和 TF 2.11)中复制上述代码时,它没有显示任何错误。您可以通过安装 python 版本 3.8 再试一次。另外,请通过提供完整的继承基础 API 名称
from tensorflow import keras来导入 keras。
标签: python tensorflow