pycharm报错如下

pycharm报错:AttributeError: module 'tensorflow_estimator.python.estimator.api._v1.estimator' has no attribute 'opt'
以下是包的版本,第一个是当前版本,第二个是最新版本
absl-py 1.1.0 0.15.0
astor 0.8.1 0.8.1
cached-property 1.5.2 1.5.2
certifi 2016.2.28 2022.6.15
cycler 0.11.0 0.11.0
dataclasses 0.8 0.8
gast 0.5.3 0.5.3
google-pasta 0.2.0 0.2.0
griddata 0.1.0
grpcio 1.47.0 1.42.0
h5py 3.1.0 3.6.0
importlib-metadata 4.8.3 4.11.3
keras-applications 1.0.8 1.0.8
keras-preprocessing 1.1.2 1.1.2
kiwisolver 1.3.1 1.4.2
markdown 3.3.7 3.3.4
matplotlib 2.2.0 3.5.1
numpy 1.16.0 1.22.3
pandas 1.1.5 1.4.3
pillow 8.4.0 9.0.1

以下是代码来源:https://github.com/maziarraissi/PINNs/tree/master/main/continuous_time_inference%20(Schrodinger)
pip 21.3.1 22.1.2
plotting 0.0.7
protobuf 3.19.4 3.20.1
pydoe 0.3.8
pyparsing 3.0.7 3.0.4
python 3.6.2 3.10.4
python-dateutil 2.8.2 2.8.2
pytz 2022.1 2022.1
scipy 1.5.4 1.7.3
seaborn 0.11.2 0.11.2
setuptools 59.6.0 61.2.0
six 1.16.0 1.16.0
tensorboard 1.14.0 2.6.0
tensorflow 1.14.0 2.6.0
tensorflow-estimator 1.14.0 2.6.0
termcolor 1.1.0 1.1.0
typing-extensions 4.1.1 4.1.1
vc 14 14.2
vs2015_runtime 14.0.25420 14.27.29016
werkzeug 2.0.3 2.0.3
wheel 0.29.0 0.37.1
wincertstore 0.2 0.2
wrapt 1.14.1 1.13.3
zipp 3.6.0 3.8.0
pip 21.3.1 22.1.2
plotting 0.0.7
protobuf 3.19.4 3.20.1
pydoe 0.3.8
pyparsing 3.0.7 3.0.4
python 3.6.2 3.10.4
python-dateutil 2.8.2 2.8.2
pytz 2022.1 2022.1
scipy 1.5.4 1.7.3
seaborn 0.11.2 0.11.2
setuptools 59.6.0 61.2.0
six 1.16.0 1.16.0
tensorboard 1.14.0 2.6.0
tensorflow 1.14.0 2.6.0
tensorflow-estimator 1.14.0 2.6.0
termcolor 1.1.0 1.1.0
typing-extensions 4.1.1 4.1.1
vc 14 14.2
vs2015_runtime 14.0.25420 14.27.29016
werkzeug 2.0.3 2.0.3
wheel 0.29.0 0.37.1

版本环境什么的都没啥问题的话,如果是复现别人的代码,看看是不是有原作者的文档没有放在同一个目录下

Tf环境冲突

文章:pycharm 基础配置 中也许有你想要的答案,请看下吧

这种情况就需要用anaconda创建一个虚拟环境,然后在虚拟环境中安装你需要的tensorflow版本,具体创建可以参考https://blog.csdn.net/qq_52785473/article/details/122543935希望对你有帮助!

  1. 包的版本不匹配,有的更新后部分函数或方法失效不再支持
  2. 使用虚拟环境安装所有依赖
  3. 检查本地以安装的包(如不指定,安装默认都是最新的)版本