无法在Cygwin的Windows Python上安装Pillow

1 投票
2 回答
2104 浏览
提问于 2025-04-18 12:01

我试着在Windows上通过Cygwin安装最新版本的Pillow,使用的命令是pip install Pillow,但是出现了错误信息:

In file included from _imagingtk.c:19:0:

/usr/include/tk.h:76:23: fatal error: X11/Xlib.h: No such file or directory

 # include <X11/Xlib.h>

                       ^

compilation terminated.

In file included from Tk/tkImaging.c:52:0:

/usr/include/tk.h:76:23: fatal error: X11/Xlib.h: No such file or directory

 # include <X11/Xlib.h>

                       ^

compilation terminated.

Building using 8 processes

gcc -shared -Wl,--enable-auto-image-base -L. build/temp.cygwin-1.7.30-x86_64-2.7/_imagingtk.o build/temp.cygwin-1.7.30-x86_64-2.7/Tk/tkImaging.o -L/usr/lib
-L/usr/lib/python2.7/config -L/usr/local/lib -L/usr/lib/python2.7/config -ltcl8.5 -ltk8.5 -lpython2.7 -o build/lib.cygwin-1.7.30-x86_64-2.7/PIL/_imagingtk.dll

gcc: error: build/temp.cygwin-1.7.30-x86_64-2.7/_imagingtk.o: No such file or directory

gcc: error: build/temp.cygwin-1.7.30-x86_64-2.7/Tk/tkImaging.o: No such file or directory

error: command 'gcc' failed with exit status 1

---------------------------------------- Cleaning up... Command /usr/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip_build_User /pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-7Gv1dT-record/install-record.txt
--single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_User/pillow

Traceback (most recent call last):   File "/usr/bin/pip", line 11, in <module>
    sys.exit(main())   File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)   File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 35: ordinal not in range(128)

出错的原因是找不到X11,这让我很困惑,因为我是在Windows电脑上,而X11是Linux的软件。我不喜欢依赖预编译的版本,因为没有支持。

2 个回答

0

对于那些还在寻找类似问题的人,这里有个原因:提问者没有安装Cygwin里包含的很多X11库。没错,如果你在用Cygwin,实际上是在使用“Linux”工具(它是一个独立的、符合POSIX标准的Windows环境……而且,是的,你可以用它运行X11服务器和客户端)。

除此之外,我现在遇到的问题是关于一些图形库(比如openjpeg),我在当前版本的Cygwin(3.4.9)和Windows(11)上遇到的……这在搜索中算是“一个命中”。

-10

和往常一样,这里给出的建议是放弃Cygwin,换一个更好的命令行工具。

撰写回答