You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入aitextgen包遇错误:无法从pytorch_lightning.utilities导入_TPU_AVAILABLE

解决ImportError: cannot import name '_TPU_AVAILABLE' from 'pytorch_lightning.utilities'

这个错误是因为新版pytorch-lightning移除了内部变量_TPU_AVAILABLE,但aitextgen的代码仍在引用该变量,仅降级PyTorch无法解决,需针对性调整pytorch-lightning版本:

  • 卸载当前版本的pytorch-lightning:
    pip uninstall -y pytorch-lightning
    
  • 安装与aitextgen兼容的旧版本(推荐1.9.5,该版本保留_TPU_AVAILABLE且与PyTorch 1.11.0兼容):
    pip install pytorch-lightning==1.9.5
    
  • 验证版本适配:执行以下命令,无报错则说明配置正确
    python -c "from pytorch_lightning.utilities import _TPU_AVAILABLE"
    
  • 重新尝试导入aitextgen:
    import aitextgen
    

内容的提问来源于stack exchange,提问作者Sudesna Baruah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 11:33:49