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