无法在 google colab 上导入 pytorch_lightning

新手上路,请多包涵

我做了以下事情:

 !pip install pytorch_lightning -qqq
import pytorch_lightning

但是得到以下错误:

 ImportError                               Traceback (most recent call last)
<ipython-input-7-d883b15aac58> in <module>()
----> 1 import pytorch_lightning

----------------------------------9 frames------------------------------------------------
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py in <module>()
     26
     27 if _TORCHTEXT_AVAILABLE:
---> 28     from torchtext.data import Batch
     29 else:
     30     Batch = type(None)

ImportError: cannot import name 'Batch' from 'torchtext.data' (/usr/local/lib/python3.7/dist-packages/torchtext/data/__init__.py)

可能是什么问题?

原文由 user15357068 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 715
1 个回答

Github 上的 Issue #6415 所述,请尝试从 GitHub 安装。

它对我有用。

 !pip install git+https://github.com/PyTorchLightning/pytorch-lightning
import pytorch_lightning as pl
print(pl.__version__)

输出:

 1.3.0dev

错误似乎来自 Issue #6210 ,他们说它已修复。我猜它没有上传到 PyPi。

原文由 PythonSnek 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题