-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to import lightning on Google Colab #17136
Comments
Reported to Google Colab too: googlecolab/colabtools#3514 |
Been struggling with this too, thanks for opening the issue @adamjstewart! Maybe we can temporarily require |
Another workaround is to only try to import rich when it's requested to use the rich progress bar. Using the |
I linked a pull request that fixes this issue temporarily. |
This was also fixed on the Google side: googlecolab/colabtools#3514 Your fix is probably more reliable though since the Google fix will be needed again the next time a newer version is required. |
Thanks for confirming it! |
yet another sin of rich, and respositories which require it and keep a shitty module alive |
Bug description
I'm trying to import lightning on Google Colab but it doesn't seem possible at the moment.
How to reproduce the bug
First thing I tried was:
Not installed. No problem, let me install it:
Nope, that fails too. Let's try ipython's reload feature:
Nope, unable to reload. I've also played around with
importlib.reload
in a few different possible places but no luck so far.Note that you have to click "Runtime > Disconnect and delete runtime" and "Reconnect" between each step.
Error messages and logs
Full stacktrace
Environment
Current environment
More info
Here is what I believe to be the source of the issue.
lightning
depends onrich
, which depends onpygments<3.0.0,>=2.13.0
. So%pip install lightning
installs a newer version ofpygments
and uninstalls thepygments==2.6.1
that comes with the environment by default. However, Jupyter relies on pygments to render the notebook, so it has already been imported. For some reason, reload doesn't seem to work (possibly related to ipython/ipython#13347).So far, I've found two possible workarounds, but no fixes. One is to run the notebook, let it crash, then "Restart runtime" so that pygments has already been upgraded and the notebook imports that instead. The other is to change the install to:
This forces pip to use an older version of rich that still supports older pygments. The former workaround is unideal because unfamiliar users won't understand the error message, while the latter workaround is unideal because it only works on Google Colab and only until pygments gets updated in the future. I'm trying to write a tutorial that works anywhere without either of these constraints.
I'm honestly not sure what if anything Lightning can do to solve this issue. One possibility would be to not check the version of rich available and instead rely on pip to do the right thing. Another possibility would be to request that Google update the default version of pygments available in Colab, but that's out of your control and may take a while. Of course, if anyone can figure out why reload isn't working, that would be the most ideal solution.
cc @tchaton
The text was updated successfully, but these errors were encountered: