项目场景:
ubuntu 18.04 安装Pillow失败
Failed building wheel for Pillow
问题描述
提示:这里描述项目中遇到的问题:
例如:数据传输过程中数据不时出现丢失的情况,偶尔会丢失一部分数据
APP 中接收数据代码:
Failed building wheel for Pillow
Running setup.py clean for Pillow
Failed to build Pillow
Installing collected packages: Pillow
Running setup.py install for Pillow ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3uxjejtl/Pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-83wulbqn-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
/usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-3uxjejtl/Pillow/setup.py", line 1037, in <module>
raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
原因分析:
缺少相应依赖,根据最后提示,到官网找:
解决方案:
到官网后,找到ubuntu16.04~20.04所需依赖列表:
直接安装即可
sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
libharfbuzz-dev libfribidi-dev libxcb1-dev
再次安装Pillow
根据实际情况 pip或pip3
pip3 --default-timeout=100 install -U Pillow
安装完成