问题描述
在导入 tflearn 时出现此错误:-
While I was importing tflearn I'm getting this error:-
导入 tflearn
回溯(最近一次调用最后一次):文件",第 1 行,在文件/Users/rohansethi/anaconda3/lib/python3.7/site-packages/tflearn/init.py",第 4 行,在从 .导入配置文件/Users/rohansethi/anaconda3/lib/python3.7/site-packages/tflearn/config.py",第5行,在from .variables 导入变量文件/Users/rohansethi/anaconda3/lib/python3.7/site-packages/tflearn/variables.py",第7行,在从 tensorflow.contrib.framework.python.ops 导入 add_arg_scope 作为 contrib_add_arg_scopeModuleNotFoundError:没有名为tensorflow.contrib"的模块
Traceback (most recent call last): File "", line 1, in File "/Users/rohansethi/anaconda3/lib/python3.7/site-packages/tflearn/init.py", line 4, in from . import config File "/Users/rohansethi/anaconda3/lib/python3.7/site-packages/tflearn/config.py", line 5, in from .variables import variable File "/Users/rohansethi/anaconda3/lib/python3.7/site-packages/tflearn/variables.py", line 7, in from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scopeModuleNotFoundError: No module named 'tensorflow.contrib'
推荐答案
您需要使用旧版本的 TensorFlow.
You need to use an older version of TensorFlow.
tensorflow.contrib
已从 tensorflow 中删除,版本 >=1.14.
Was removed from tensorflow with versions >=1.14.
这是你可以做的:
pip uninstall tensorflow
pip install tensorflow==1.14
要检查是否一切正常:在控制台中输入 python
启动 python 然后:
To check if everything is working fine:Start python in the console by typing python
Then:
import tensorflow
tensorflow.__version__
它应该显示 1.14.现在您可以运行您的程序了.
It should show you 1.14.Now you can run your program.
这篇关于导入 tflearn 时没有名为“tensorflow.contrib"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!