繁体   English   中英

Mac M1 和 Jupyter Notebook 上的 tensorflow_hub 导入错误(很可能是由于循环导入)

[英]tensorflow_hub import error (most likely due to a circular import) on Mac M1 and Jupyter Notebook

环境是 Mac M1 和 miniforge Conda with python3.8。 我已经完成了以下命令来安装tensorflow和tensorflow_hub:

conda install -c apple tensorflow-deps
pip install tensorflow-macos
pip install tensorflow-metal

# tried all the conda commands here (https://anaconda.org/conda-forge/tensorflow-hub) and the following
pip install tensorflow_hub

在 Jupyter Notebook 上导入 tensorflow_hub 时,出现以下错误:

cannot import name 'LinearSDCA' from partially initialized module 
'tensorflow_estimator.python.estimator.canned.linear' (most likely due to a circular import)
 (/myenv/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/canned/linear.py)

使用终端导入tensorflow_hub时,报错信息为:

E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers
...Traceback...
self._metric = self._metric_methods[self._label_length].create(*args)
tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.

目前我的tensorflow_estimator版本是2.6.0,tensorflow_hub版本是0.12.0。 我尝试更改 tensorflow_estimator 的版本。 但是,我能够安装而没有错误的唯一 tensorflow-macos 版本是 2.6.0,它需要 tensorflow_estimator 2.6.0。 感谢您的时间和您可以提供的任何帮助。

是否安装了 keras 2.7? 如果是这样,请通过pip install -U keras==2.6.0降级它,因为它与 TF 2.6 不兼容。 TF 2.6.2修复了某些依赖项的上限,因此该版本应该可以开箱即用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM