我正在嘗試使用easy-pil為discord.py制作等級卡。我遇到python無法在ubuntu上匯入模塊的問題,并且出現錯誤。
這是要匯入的檔案的頂部
from easy_pil import Editor, Canvas, Font, load_image, Text
這是我得到的錯誤
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)
我是否缺少要匯入的內容,或者某些內容安裝不正確?
uj5u.com熱心網友回復:
該錯誤是由根據檔案Literal添加到typing版本 3.8 中的 python 標準庫模塊的事實引起的。
easy-pil的setup.py與Python 3.7 權利要求的相容性,因此這顯然是一個錯誤。
我冒昧地在 GitHub 上報告了這個問題(參考了這個問題):https : //github.com/shahriyardx/easy-pil/issues/3。與此同時,將您的 python 升級到 3.8 以獲得簡單的解決方法。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/372436.html
上一篇:在熊貓中按條件切換列值
