Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

python 3.7 cannot import easy-pil

I am trying to use Easy pill to make rank cards for discord.py. I have the problem that python cannot import the modules on ubuntu, and I get the error.

This is at the top of the file to import

from easy_pil import Editor, Canvas, Font, load_image, Text

This is the error I get

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Traceback (most recent call last):
  File "bot.py", line 9, in <module>
    from easy_pil import Editor, Canvas, Font, load_image, Text
  File "/usr/local/lib/python3.7/dist-packages/easy_pil/__init__.py", line 3, in <module>
    from .editor import Editor
  File "/usr/local/lib/python3.7/dist-packages/easy_pil/editor.py", line 2, in <module>
    from .font import Font
  File "/usr/local/lib/python3.7/dist-packages/easy_pil/font.py", line 3, in <module>
    from typing import Literal
ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)

Am I missing something to import, or has something been installed incorrectly?

>Solution :

The error is caused by the fact that Literal was added to the python standard library’s typing module in version 3.8 according to the docs.

easy-pil‘s setup.py claims compatibility with python 3.7+, so this is clearly a bug.

I’ve taken the liberty of reporting this on GitHub (citing this question): https://github.com/shahriyardx/easy-pil/issues/3. In the meantime upgrade your python to 3.8+ for an easy workaround.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading