我在我的应用程序中使用 openpyxl python 包。使用时我收到以下消息。
/usr/local/lib/python2.7/dist-packages/openpyxl/init.py:31: UserWarning: The installed version of lxml is too old to be used with openpyxl
warnings.warn("The installed version of lxml is too old to be used with openpyxl")
Openpyxl需要lxml 3.2.5或以上版本,我机器上的版本是3.2.0。当我尝试将 lxml 升级到最新版本时,即 3.3.5,它被以下消息打断。
i686-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-2.7/lxml/etree.so
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'i686-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml
Replacing /usr/lib/python2.7/dist-packages/lxml
Replacing /usr/lib/python2.7/dist-packages/lxml-3.2.0.egg-info
Cleaning up...
Removing temporary dir /tmp/pip_build_root...
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ov0PUy-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip_build_root/lxml
我需要帮助来解决这个问题。
PS:- 我已经在我的机器上安装了 lxml 依赖包 python-dev、libxml2-dev 和 libxslt1-dev。
请您参考如下方法:
sudo pip install --upgrade lxml
