Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/PIL/ImageDraw.py", line 463, in draw_text
mask, offset = font.getmask2(
^^^^^^^^^^^^^
AttributeError: 'ImageFont' object has no attribute 'getmask2'. Did you mean: 'getmask'?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/01_LCD_ok/LCD_demo.py", line 352, in <module>
main_lcd3()
File "/home/user/01_LCD_ok/LCD_demo.py", line 260, in main_lcd3
show_img_exif(file_path_tmp)
File "/home/user/01_LCD_ok/LCD_demo.py", line 123, in show_img_exif
disp.display_text_exif(str)
File "/home/user/01_LCD_ok/lib/LCD_ILI9488_lib.py", line 354, in display_text_exif
draw.text((x, y), text, font=font, fill=color)
File "/usr/lib/python3/dist-packages/PIL/ImageDraw.py", line 520, in text
draw_text(ink)
File "/usr/lib/python3/dist-packages/PIL/ImageDraw.py", line 479, in draw_text
mask = font.getmask(
^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 179, in getmask
return self.font.getmask(text, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
尝试通过draw.text((x, y), text, font=font, fill=color),显示text = “你好“,但是发现缺少getmask2。
pip install --upgrade pillow
升级pillow,却被提示无法安装
user@starfive:~/01_LCD_ok$ pip install --upgrade pillow
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
请问有没有人尝试过通过lcd显示中文?