我在尝试在我的 Windows 10 机器上运行 TensorFlow 时遇到问题。代码在我的 MacOS 机器上运行良好。
Traceback (most recent call last):
File "c:\Users\Fynn\Documents\GitHub\AlpacaTradingBot\ai.py", line 15, in <module>
from keras.models import Sequential, load_model
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras__init__.py", line 24, in <module>
from keras import models
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\models__init__.py", line 18, in <module>
from keras.engine.functional import Functional
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\functional.py", line 24, in <module>
from keras.dtensor import layout_map as layout_map_lib
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\dtensor__init__.py", line 22, in <module>
from tensorflow.compat.v2.experimental import dtensor as dtensor_api # pylint: disable=g-import-not-at-top
ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental' (C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow_api\v2\compat\v2\experimental__init__.py)
原文由 Fynn 发布,翻译遵循 CC BY-SA 4.0 许可协议
我尝试了很多解决方案都无济于事,最后这对我有用!