python - 我发现 ModuleNotFoundError: No module named 'tensorflow.contrib'
问题描述
我尝试在 CMD 上运行 python。我在我的 python 文件中导入 tensorflow.contrib。
import tensorflow.contrib.tensorrt as trt
使用此命令在 anaconda 上运行时。
python run_webcam.py --camera yoga.mp4
它显示错误:
File "run_webcam.py", line 8, in <module>
from tf_pose.estimator import TfPoseEstimator
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\__init__.py", line 5, in <module>
from tf_pose.runner import infer, Estimator, get_estimator
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\runner.py", line 8, in <module>
from tf_pose import eval
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\eval.py", line 13, in <module>
from tf_pose.estimator import TfPoseEstimator
File "D:\work\pose estimation\tf-pose-estimation\tf_pose\estimator.py", line 14, in <module>
import tensorflow.contrib.tensorrt as trt
ModuleNotFoundError: No module named 'tensorflow.contrib'
我安装了
pip install tensorflow
并更改 tensorflow 的版本(尝试卸载并安装多个版本)
pip uninstall tensorflow
pip install tensorflow==...
但显示相同的错误
解决方案
尝试替换以下
import tensorflow.contrib.tensorrt as trt
(用于 ≤ TensorFlow 1.13.1 )
和
from tensorflow.python.compiler.tensorrt import trt
(TensorFlow ≥ 1.14.1)
归功于GitHub
推荐阅读
- javascript - 为什么在 Javascript 中某些代码行先于其他代码行执行?没有一个是异步的
- flutter - 当我跑步时,我得到了这个
- javascript - 当我使用选择器正常功能时,ReactJs 状态正在循环中触发
- html - 绝对定位元素在使用过滤器的活动时丢失位置
- typescript - Typescript 泛型类型和多态性
- react-native - 如何使用 React Navigation v5 使用嵌套导航保持初始路线?
- python - 如果与主要刻度一致,则不会出现 Matplotlib 次要刻度
- python - 尝试抓取的 URL 会加载不同的页面
- reactjs - 动态(和全局)设置在 react-native 中聚焦的输入字段
- python - 如何合并和计算两个数据框?