'error then import pytorch-lightning, azure notebook

i am use microsoft azure (for students) ML servise. Then i work with notebook i can not import pytorch-lightning libary.

!pip install pytorch-lightning==0.9.0 
import pytorch_lightning as pl

Here i have error:

ModuleNotFoundError                       Traceback (most recent call last)
Input In [1], in <module>
----> 2 import pytorch_lightning as pl

ModuleNotFoundError: No module named 'pytorch_lightning'

This is unbearably weird. someone faced such a problem?



Solution 1:[1]

This is rather strange but could be related to that your installation is in another location, so let's:

  1. try where is PL installed with find -name "lightning"
  2. also, check what is the loaded package locations python -c "import sys; print(sys.path)"

I guess that the problem will be in What's the difference between dist-packages and site-packages?

Solution 2:[2]

I resolved this problem by installing PyTorch-lightning in the kernel instead of the machine. It all boils down to installing with %conda magic instead of !conda magic (or same thing for %pip magic instead of !pip magic).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jirka
Solution 2 Malcolm