在Windows 7的virtualenv中用pip安装PIL时出现错误退出状态2

7 投票
1 回答
6189 浏览
提问于 2025-04-16 12:00

我在我的虚拟环境中通过pip安装PIL,但遇到了这个错误。

C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IlibImaging -Ic:\My_Pro
jects\testenv\include -Ic:\My_Projects\testenv\PC /Tc_imaging.c /Fobuild\temp.win32-2.7\Release\_imaging.obj

_imaging.c

_imaging.c(75) : fatal error C1083: Cannot open include file: 'Python.h': No such file or directory

error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

----------------------------------------
Command c:\My_Projects\testenv\Scripts\python.exe -c "import setuptools;__file__='C:\\My_Projects\\testenv\\pinax-solcia
l-site\\build\\PIL\\setup.py';execfile(__file__)" install --single-version-externally-managed --record c:\users\darren\a
ppdata\local\temp\pip-fdzgwn-record\install-record.txt failed with error code 1
Storing complete log in C:\Users\Darren\AppData\Roaming\pip\pip.log

我查看了这个问题,里面提到要安装python-dev,但那位用户是在Ubuntu系统上。我现在是在Windows 7上,不知道该怎么解决我的问题。

谢谢。

1 个回答

1

看起来VisualStudio编译器找不到Python的开发源代码。也许你需要设置一个特定的环境变量?

这篇博客似乎建议你需要把 c:\Python27c:\Python27\bin 加入到你的路径中。也许这就是缺少的部分?

PIL(Python Imaging Library)也常常和 setuptools 发生问题。你有没有试过 pillow

撰写回答