-
Notifications
You must be signed in to change notification settings - Fork 18
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
Incompatible with Google Colab (Python 3.7) #17
Comments
Simple fix suggested here.
|
There are a few other 3.8+ features janosh likes and uses all the time that make it more than just the type hints to work on 3.7 we tried for a while to support it for me but then gave up |
@CompRhys ah, good to know. Thanks! |
I'm also now noticing the Python 3.8+ badge prominently displayed on the README 😅 |
@CompRhys Just 1 other feature actually which are self-documenting f-strings try:
from typing import Literal
except ImportError:
from typing_extensions import Literal for a while but since it only solves some of the problem, I got rid of it again. Supposedly it's possible to set up python 3.8 on Colab. I've never tried it myself, but perhaps you wanna give it a shot. I don't see much point in 3.7 support at this point since |
@janosh Thanks for linking the PR. I actually didn't know about self-documenting f-strings until you mentioned it. Very convenient! Since the packages you mentioned all used to support 3.7, I'd imagine that for most of these Google Colab is installing older compatible versions rather than the latest ones (due to e.g. a The workaround to install python 3.8 via Anaconda might lessen some of that newcomer friendliness, but I'll keep it in mind if there's a more pressing need. |
Yes, big fan here. 😄 There should be a version of There are 2 long-standing issues on upgrading the OS on which Colab runs which would also update the Python version it offers:
Unfortunately, that endeavor seems to have stalled quite badly. Not sure why it's so difficult. You may want to subscribe there for updates. |
Thanks for the info! I knew it wasn't supported but didn't know why. I might poke around with the older versions and see which one I can install. |
A workaround for this might be to perform a local installation via cloning and modifying the self-documenting f-strings: Clone!git clone https://github.com/janosh/pymatviz.git
%cd pymatviz Modify f-stringsimport os, fnmatch
def findReplace(directory, find, replace, filePattern):
"""https://stackoverflow.com/a/6257321/13697228"""
for path, dirs, files in os.walk(os.path.abspath(directory)):
for filename in fnmatch.filter(files, filePattern):
filepath = os.path.join(path, filename)
with open(filepath) as f:
s = f.read()
s = s.replace(find, replace)
with open(filepath, "w") as f:
f.write(s) # to make compatible with Python 3.7
findReplace("pymatviz", "=}", "}", "*.py") This seemed to work OK for another use-case (CDVAE on Colab). Will probably try it out next time I'm surfacing an example of some package on Colab and want to use pymatviz. |
I'm getting a Pylance warning stating that use of Lines 21 to 24 in c4381d3
Though the tests, which are on Python 3.8, seem to be working fine. I guess it's probably because |
If it's just a warning, I think it's safe to ignore. But I'm still surprised. Pylance should know better. from __future__ import annotations backports the pipe operator for unions and other modern type-hint syntax all the way to py37. |
Ah, got it! Thanks @janosh |
Just in the process of splicing out your nice |
Glad if it can be useful. 😄 |
Would it be too painful to create a release and version compatible with Python 3.7 via the above script (and with So many times I've wanted to use pymatviz on Google Colab 😅 For visualization, I'm using ase instead (for now) |
Not much pain i.t.o. workload. Should just take a few minutes. The pain is more psychological. 😄 |
Hmm.. yeah the really old Python version is disappointing. I still find it very convenient for sharing teaching examples, but I think I can understand the psychological pain 😅😭. Thanks for fulfilling my selfish request 🙏 |
The text was updated successfully, but these errors were encountered: