pytorch-lightning安装报错module 'pytorch_lightning' has no attribute '_C'

问题描述:
安装pytorch_lightning时出现报错 module 'pytorch_lightning' has no attribute '_C'
torch版本pytorch==1.12.0,py3.7_cuda11.3_cudnn8_0, torchaudio==0.12.0,torchvision==0.13.0

提供远程技术支持

您可以参照以下链接:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pytorch
下载指定的whl文件,再在命令行输入pip install whl文件路径,就可以成功安装whl的pytorch,试试可不可以

八成是需要科学上网就解决了

这个错误通常是由于PyTorch Lightning的安装不完整或与您的Python版本不兼容引起的。

以下是一些可能的解决方案:

确保您已经安装了最新版本的PyTorch和PyTorch Lightning。您可以使用以下命令安装最新版本:

pip install torch torchvision torchaudio pytorch_lightning -U
确保您的Python版本与PyTorch Lightning兼容。目前,PyTorch Lightning支持Python 3.6及更高版本。如果您的Python版本太低或太高,则可能会出现此错误。

尝试重新安装PyTorch Lightning。您可以使用以下命令卸载并重新安装:

pip uninstall pytorch_lightning
pip install torch torchvision torchaudio pytorch_lightning -U
如果您使用的是conda环境,请确保在激活环境时安装了正确的包。例如,如果您在名为“myenv”的环境中安装了PyTorch Lightning,则应使用以下命令激活环境并安装缺失的包:

conda activate myenv
pip install torch torchvision torchaudio pytorch_lightning -U
如果上述方法都无法解决您的问题,请提供更多详细信息,以便我能够提供更具体的解决方案。

该错误通常表示您安装的PyTorch和PyTorch-Lightning版本不兼容。请确保您使用的PyTorch-Lightning版本与您安装的PyTorch版本兼容。您可以在PyTorch-Lightning的GitHub页面上找到支持的PyTorch版本列表。请尝试通过升级或降级PyTorch-Lightning版本来解决此错误。

另外,请确保您正确安装了所有依赖项(如cuda、cudnn等)。如果您的环境中存在多个版本的PyTorch或其他库,请尝试卸载其他版本并重新安装所需版本的库。

最后,如果问题仍然存在,请尝试在新的虚拟环境中安装PyTorch和PyTorch-Lightning,以确保没有其他库的冲突。

img


安装命令:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytorch_lightning