Schemdraw is not compatible with Python 3.7

Issue #49 resolved
Former user created an issue

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)

  1. Yossi Oren

    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'>
    

  2. cdelker 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.

  3. Yossi Oren

    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!

  4. Log in to comment