Schemdraw is not compatible with Python 3.7
From the documentation:
https://schemdraw.readthedocs.io/en/latest/usage/start.html
Schemdraw requires Python 3.7+. Python 3.8+ is recommended for its walrus operator (:=) that allows a more compact notation of defining schematics.
However, Schemdraw imports Literal from typing.py, which is not supported in version 3.7. Can document which versions of Schemdraw are 3.7 compatible?
Comments (8)
-
repo owner -
Hi, this breaks compatibility of Schemdraw with Google Colab, which is using a 3.7 runtime right now. Still works if I force version 0.8, as shown below.
!pip install schemdraw import schemdraw print(schemdraw)
Collecting schemdraw Downloading (82kB) |████████████████████████████████| 92kB 8.7MB/s Installing collected packages: schemdraw Successfully installed schemdraw-0.10 --------------------------------------------------------------------------- ImportError Traceback (most recent call last) in <module>() 1 get_ipython().system('pip install schemdraw') ----> 2 import schemdraw 3 print(schemdraw)
in <module>() 3 from __future__ import annotations 4 ----> 5 from typing import Literal, Type, Any 6 from collections import ChainMap 7 import warnings ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py) --------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below. ---------------------------------------------------------------------------
!pip install schemdraw==0.8 import schemdraw print(schemdraw)
Collecting schemdraw==0.8 Downloading https://files.pythonhosted.org/packages/87/c2/c64538e9213b7927da7cd797e3b77a32ddfb69c094b3c32eeac605f1e900/schemdraw-0.8-py3-none-any.whl (53kB) |████████████████████████████████| 61kB 4.7MB/s Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from schemdraw==0.8) (3.2.2) Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from schemdraw==0.8) (1.19.5) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->schemdraw==0.8) (2.4.7) Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->schemdraw==0.8) (0.10.0) Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->schemdraw==0.8) (2.8.1) Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->schemdraw==0.8) (1.3.1) Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from cycler>=0.10->matplotlib->schemdraw==0.8) (1.15.0) Installing collected packages: schemdraw Found existing installation: schemdraw 0.10 Uninstalling schemdraw-0.10: Successfully uninstalled schemdraw-0.10 Successfully installed schemdraw-0.8 <module 'schemdraw' from '/usr/local/lib/python3.7/dist-packages/schemdraw/__init__.py'>
-
As Guido says, if this package wants to support 3.7, it will need to depend on
typing_extensions
from PyPI and use that for types added later in Python’s lifetime: https://github.com/python/typing/issues/707#issuecomment-603972535 -
schemdraw
only supports Python 3.8+ as documented in this commit: https://bitbucket.org/cdelker/schemdraw/commits/a69a692ff26cb4d7f6032c74472e4622951a27d6 -
repo owner 7227aae
adds conditional import of typing_extensions. Also drops use of math.dist, a Python 3.8-only function. Everything appears to work in 3.7 now, with the exception of some documentation/test examples that use the walrus operator. -
@cdelker Would you be able to publish a new release on PyPI that includes this and pull request #20? Thanks.
-
repo owner - changed status to resolved
0.11 released. fb2840e
-
Verified that Schemdraw now works on Google Colab:
!pip install schemdraw import schemdraw print(schemdraw) Collecting schemdraw Downloading (84kB) |████████████████████████████████| 92kB 6.4MB/s Requirement already satisfied: typing-extensions; python_version < "3.8" in /usr/local/lib/python3.7/dist-packages (from schemdraw) (3.7.4.3) Installing collected packages: schemdraw Successfully installed schemdraw-0.11 <module 'schemdraw' from '/usr/local/lib/python3.7/dist-packages/schemdraw/__init__.py'>
Thanks a lot, John and Collin!
- Log in to comment
Reference: https://github.com/python/typing/issues/707