I tried to refactor my python code to use Pytorch-Lightning. However I’ve faced the problem that I can’t import Pytorch-Lightning library. I get this error:
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 14
12 from fastai.vision.all import *
13 from ipywidgets import IntProgress
---> 14 import pytorch_lightning as pl
ModuleNotFoundError: No module named 'pytorch_lightning'
It doesn’t see pytorch_lightning and lightning when importing.
I have only one python environment and kernel(I’m using Jupyter Notebook in Visual Studio Code).
When I check pip list, I get this output:
Package Version
------------------------ -------------
aiohttp 3.8.4
aiosignal 1.3.1
anyio 3.6.2
apturl 0.5.2
arrow 1.2.3
async-timeout 4.0.2
attrs 22.2.0
Automat 0.8.0
backcall 0.1.0
bcrypt 3.1.7
beautifulsoup4 4.12.0
bleach 3.1.1
blessed 1.20.0
blinker 1.4
Brlapi 0.7.0
certifi 2022.12.7
chardet 3.0.4
charset-normalizer 3.1.0
Click 7.0
cloud-init 22.4.2
cmake 3.26.1
colorama 0.4.3
command-not-found 0.3
configobj 5.0.6
constantly 15.1.0
croniter 1.3.8
cryptography 2.8
cupshelpers 1.0
dateutils 0.6.12
dbus-python 1.2.16
decorator 4.4.2
deepdiff 6.3.0
defer 1.0.6
defusedxml 0.6.0
distro 1.4.0
distro-info 0.23ubuntu1
dnspython 2.3.0
duplicity 0.8.12.0
email-validator 1.3.1
entrypoints 0.3
fastapi 0.88.0
fasteners 0.14.1
filelock 3.11.0
frozenlist 1.3.3
fsspec 2023.4.0
future 0.18.2
h11 0.14.0
html5lib 1.0.1
httpcore 0.16.3
httplib2 0.14.0
httptools 0.5.0
httpx 0.23.3
hyperlink 19.0.0
idna 3.4
importlib-metadata 1.5.0
incremental 16.10.1
inquirer 3.1.3
install 1.3.5
ipykernel 5.2.0
ipython 7.13.0
ipython_genutils 0.2.0
ipywidgets 6.0.0
itsdangerous 2.1.2
jedi 0.15.2
Jinja2 3.1.2
jsonpatch 1.22
jsonpointer 2.0
jsonschema 3.2.0
jupyter-client 6.1.2
jupyter-core 4.6.3
keyring 18.0.1
language-selector 0.1
launchpadlib 1.10.13
lazr.restfulclient 0.14.2
lazr.uri 1.0.3
lightning 2.1.0.dev0
lightning-cloud 0.5.32
lightning-utilities 0.8.0
lit 16.0.0
lockfile 0.12.2
louis 3.12.0
macaroonbakery 1.3.1
Mako 1.1.0
markdown-it-py 2.2.0
MarkupSafe 2.1.2
mdurl 0.1.2
mistune 0.8.4
monotonic 1.5
more-itertools 4.2.0
mpmath 1.3.0
multidict 6.0.4
nbconvert 5.6.1
nbformat 5.0.4
netifaces 0.10.4
networkx 3.1
notebook 6.0.3
numpy 1.24.2
nvidia-cublas-cu11 11.10.3.66
nvidia-cuda-cupti-cu11 11.7.101
nvidia-cuda-nvrtc-cu11 11.7.99
nvidia-cuda-runtime-cu11 11.7.99
nvidia-cudnn-cu11 8.5.0.96
nvidia-cufft-cu11 10.9.0.58
nvidia-curand-cu11 10.2.10.91
nvidia-cusolver-cu11 11.4.0.1
nvidia-cusparse-cu11 11.7.4.91
nvidia-nccl-cu11 2.14.3
nvidia-nvtx-cu11 11.7.91
oauthlib 3.1.0
olefile 0.46
ordered-set 4.1.0
orjson 3.8.9
packaging 23.0
pandocfilters 1.4.2
paramiko 2.6.0
parso 0.5.2
pexpect 4.6.0
pickleshare 0.7.5
Pillow 7.0.0
pip 23.0.1
prometheus-client 0.7.1
prompt-toolkit 2.0.10
protobuf 3.6.1
psutil 5.9.4
pyasn1 0.4.2
pyasn1-modules 0.2.1
pycairo 1.16.2
pycups 1.9.73
pydantic 1.10.7
Pygments 2.14.0
PyGObject 3.36.0
PyHamcrest 1.9.0
PyJWT 1.7.1
pymacaroons 0.13.0
PyNaCl 1.3.0
pyOpenSSL 19.0.0
pyprof2calltree 1.4.4
pyRFC3339 1.1
pyrsistent 0.15.5
pyserial 3.4
python-apt 2.0.1
python-dateutil 2.8.2
python-debian 0.1.36ubuntu1
python-dotenv 1.0.0
python-editor 1.0.4
python-multipart 0.0.6
pytorch-lightning 2.0.1
pytz 2019.3
pyxdg 0.26
PyYAML 6.0
pyzmq 18.1.1
ranger-fm 1.9.3
readchar 4.0.5
reportlab 3.5.34
requests 2.28.2
requests-unixsocket 0.2.0
rfc3986 1.5.0
rich 13.3.3
screen-resolution-extra 0.0.0
SecretStorage 2.3.1
Send2Trash 1.5.0
service-identity 18.1.0
setuptools 67.6.1
simplejson 3.16.0
six 1.14.0
sniffio 1.3.0
sos 4.4
soupsieve 2.4
ssh-import-id 5.10
starlette 0.22.0
starsessions 1.3.0
sympy 1.11.1
systemd-python 234
terminado 0.8.2
testpath 0.4.4
torch 2.0.0
torchmetrics 0.11.4
tornado 5.1.1
tqdm 4.65.0
traitlets 5.9.0
triton 2.0.0
Twisted 18.9.0
typing_extensions 4.5.0
ubuntu-advantage-tools 8001
ubuntu-drivers-common 0.0.0
ufw 0.36
ujson 5.7.0
unattended-upgrades 0.1
urllib3 1.26.15
usb-creator 0.3.7
uvicorn 0.21.1
uvloop 0.17.0
wadllib 1.3.3
watchfiles 0.19.0
wcwidth 0.1.8
webencodings 0.5.1
websocket-client 1.5.1
websockets 10.4
wheel 0.40.0
widgetsnbextension 2.0.0
xkit 0.0.0
yarl 1.8.2
zipp 1.0.0
zope.interface 4.7.1
As you can see, there is a Pytorch-Lightning library installed, however even when I uninstall, reinstall with newest version, install again through GitHub repository, updated, nothing works. What seems to be a problem?
2
Answers
The API of newest version of pl has been changed.
You can try:
moving forward with PyTorch Lightning 2.0, correct way to import is –
We also published an upgrade guide here