属性错误:模块'tensorflow'没有属性'compat'。

问题描述 投票:0回答:1

由于我的CPU不支持AVX指令,而且我想安装一个较新版本的Tensorflow(>= 2.0),我为我的Python版本安装了一个tensorflow轮子,从 https:/github.comfo40225tensorflow-windows-wheel)。 使用pip

然而,当尝试导入tensorflow时,我得到以下错误。

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\__init__.py", line 45, in <module>
    from . _api.v2 import compat
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\__init__.py", line 23, in <module>
    from . import v1
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\__init__.py", line 664, in <module>
    from tensorflow_estimator.python.estimator.api._v1 import estimator
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\__init__.py", line 10, in <module>
    from tensorflow_estimator._api.v1 import estimator
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\_api\v1\estimator\__init__.py", line 10, in <module>
    from tensorflow_estimator._api.v1.estimator import experimental
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\_api\v1\estimator\experimental\__init__.py", line 10, in <module>
    from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\canned\dnn.py", line 33, in <module>
    from tensorflow_estimator.python.estimator import estimator
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 53, in <module>
    from tensorflow_estimator.python.estimator import util as estimator_util
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\util.py", line 75, in <module>
    class _DatasetInitializerHook(tf.compat.v1.train.SessionRunHook):
AttributeError: module 'tensorflow' has no attribute 'compat'

我搜索了一下,但没有发现有人使用 tensorflow wheel 遇到同样的问题(仅仅通过 "pip install tensorflow "来安装 tensorflow 对我来说是行不通的,因为我会遇到 ImportError.DLL load failed-error)。DLL load failed-error)。)

希望有人能帮忙。

python tensorflow avx python-wheel
1个回答
0
投票

如果你想安装Tensorflow,使用 pip install Tensorflow 在你的CPU中,那么可能的原因是收到 DLL load failed-error 是你没有 Microsoft Visual C++ 2015-2019 Redistributable (x64).

请安装 Microsoft Visual C++ 2015-2019 Redistributable (x64)此处

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.