Linux_ImportError: cannot import name ‘ImageTk‘ from ‘PIL‘

PyQt5用不了,换tkinter写了个测试程序试试,果不其然又有报错:

ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)

最骚的的是PIL库我明明是已经装上的:

root@ubuntu:/home/user/DVP2-Linux64_2020.12.3/Python/demo# pip3 install Pillow
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (7.0.0)

解决:

安装依赖包:

apt-get install libjpeg8-dev
apt-get install zlib1g-dev
apt-get install libwebp-dev

 建立软连接

ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libwebp.so /usr/lib

 重装PIL

pip3 install -I pillow

 

你可能感兴趣的:(Linux,linux,python,tkinter)