我发现这里有一个关于类似事情的老问题:
如何在Windows上安装PyCairo(Python的Cairo)?
由于是2012年发布的,我猜它已经过时了。
我正在尝试在我的Windows 7 64位笔记本电脑上安装pycairo,我已经安装了Python 3.6.3。如果有用的话,我还安装了最新的setuptools。
我遇到了下面的错误。
C:\Programs\Python36>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z
C:\Programs\Python36>pip install pycairo
Collecting pycairo
Using cached pycairo-1.15.4.tar.gz
Installing collected packages: pycairo
Running setup.py install for pycairo ... error
Complete output from command c:\programs\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\petr
op01\\AppData\\Local\\Temp\\pip-build-vbfoifen\\pycairo\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().
replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\petrop01\AppData\Local\Temp\
pip-rrp9zlme-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\cairo
copying cairo\__init__.py -> build\lib.win-amd64-3.6\cairo
running build_ext
building 'cairo._cairo' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\cairo
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\prog
rams\python36\include -Ic:\programs\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:
\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-
IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tccairo/devic
e.c /Fobuild\temp.win-amd64-3.6\Release\cairo/device.obj
device.c
c:\users\petrop01\appdata\local\temp\pip-build-vbfoifen\pycairo\cairo\pycairo.h(37): fatal error C1083: Cannot open inclu
de file: 'cairo.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit statu
s 2
----------------------------------------
Command "c:\programs\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\petrop01\\AppData\\Local\\Te
mp\\pip-build-vbfoifen\\pycairo\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.
close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\petrop01\AppData\Local\Temp\pip-rrp9zlme-record\inst
all-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\petrop01\AppData\Local\Tem
p\pip-build-vbfoifen\pycairo\
C:\Programs\Python36>
由于我对Python及其所有内容都很陌生,这听起来对我来说太多了。据我所知,pycairo不是一个纯Python包,因此需要Visual C++ 14编译器(我刚从这里安装了它:http://landinghub.visualstudio.com/visual-cpp-build-tools,我选择了2015版本)。
但是,当我运行pip install pycairo
命令时,仍然遇到相同的问题。