Getting error, ModuleNotFoundError: No module named 'tensorflow.python.util
I've tried uninstalling and reinstalling more than 10 times, and tried different variations pip install tensorflow_gpu, pip install tensorflow --user, and also upgraded my pip. But still this error keeps happening when I try to import keras.models from tensorflow to run a model.
Does anyone know how to resolve the issue? Thanks in advance.
The full error I am getting:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-67-114c1607a26b> in <module>
4 from datetime import datetime
5 import numpy as np
----> 6 from tensorflow import keras
7 from keras.models import Sequential
8 from keras.layers import LSTM
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\__init__.py in <module>
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
39
---> 40 from tensorflow.python.eager import context
41 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
42
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\context.py in <module>
34 from tensorflow.core.protobuf import rewriter_config_pb2
35 from tensorflow.python import pywrap_tfe
---> 36 from tensorflow.python import tf2
37 from tensorflow.python.client import pywrap_tf_session
38 from tensorflow.python.eager import executor
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\tf2.py in <module>
24
25 from tensorflow.python.platform import _pywrap_tf2
---> 26 from tensorflow.python.util.tf_export import tf_export
27
28
ModuleNotFoundError: No module named 'tensorflow.python.util
我的猜测是 pip 正在为 python 2 安装它,然后你在 python 3 中运行。我已经看到了这种行为,然后需要使用 pip3。
也许你可以尝试添加或检查你的路径,因为我之前也遇到过这个问题......这是我尝试过的教程,也许你可以尝试https://superuser.com/questions/1372793/the-script-is-安装在目录中的不是路径
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.