运行Bumbles Private Detector时抛出堆栈跟踪错误,求解决方法
问题
尝试运行Bumbles Private Detector项目,已通过Anaconda创建并激活指定环境,执行脚本时出现以下导入错误:
2023-04-01 19:03:23.867874: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll Traceback (most recent call last): File "inference.py", line 7, in <module> from private_detector.utils.preprocess import preprocess_for_evaluation File "C:\Users\Andrew\Desktop\private-detector\private_detector\utils\preprocess.py", line 7, in <module> import tensorflow_addons as tfa File "C:\Users\Andrew\.conda\envs\private_detector\lib\site-packages\tensorflow_addons\__init__.py", line 22, in <module> from tensorflow_addons import callbacks File "C:\Users\Andrew\.conda\envs\private_detector\lib\site-packages\tensorflow_addons\callbacks\__init__.py", line 17, in <module> from tensorflow_addons.callbacks.average_model_checkpoint import AverageModelCheckpoint File "C:\Users\Andrew\.conda\envs\private_detector\lib\site-packages\tensorflow_addons\callbacks\average_model_checkpoint.py", line 17, in <module> from typeguard import typechecked File "C:\Users\Andrew\.conda\envs\private_detector\lib\site-packages\typeguard\__init__.py", line 4, in <module> from ._checkers import TypeCheckerCallable as TypeCheckerCallable File "C:\Users\Andrew\.conda\envs\private_detector\lib\site-packages\typeguard\_checkers.py", line 56, in <module> from typing_extensions import ( ImportError: cannot import name 'LiteralString' from 'typing_extensions' (C:\Users\Andrew\.conda\envs\private_detector\lib\site-packages\typing_extensions.py)
解决方案
原因
LiteralString是typing_extensions 4.1.0版本才新增的类型,当前环境中安装的typing_extensions版本过低,无法满足typeguard的依赖要求。
修复步骤
- 激活你的conda环境:
conda activate private_detector
- 升级
typing_extensions到满足要求的版本:
pip install --upgrade typing_extensions
- 如果升级后仍有冲突,可以指定兼容的版本(比如4.1.0或更高):
pip install typing_extensions>=4.1.0
- 重新运行项目脚本即可。
内容的提问来源于stack exchange,提问作者Andrew Aubury
相关产品推荐
相关产品推荐

