在Windows上安装PyCairo [英] Installation of PyCairo on Windows

查看:228
本文介绍了在Windows上安装PyCairo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这里有一个类似问题的老问题:

I see there is an old question about a similar thing here:

如何安装PyCairo(适用于Python的Cairo) )在Windows上?

自2012年以来,我想它已经过时了.

Since it's from 2012, I guess it's out of date.

我正在尝试在装有Python 3.6.3的Windows 7 64位笔记本电脑上安装pycairo.如果重要的话,我还安装了最新的setuptools.

I am trying to install pycairo on my Windows 7 64-bit laptop where I have Python 3.6.3 installed. I also have the latest setuptools installed if that matters.

我正面临以下错误.

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版).

Since I am knew to Python and to all its things this sounds like too much for me. As far as I understand this pycairo is not a pure Python package so it requires a Visual C++ 14 compiler (which I just installed from here: http://landinghub.visualstudio.com/visual-cpp-build-tools, I took the 2015 version).

但是当我运行pip install pycairo命令时,我仍然遇到同样的问题.

But I am still having the same issue when I run the pip install pycairo command.

推荐答案

您正在尝试安装 pycairo 来自Windows上的源代码,需要Windows C编译器.

You are trying to install pycairo from source on Windows, which requires a Windows C compiler.

您可以尝试用于Python扩展包的非官方Windows二进制文件网站.您可以找到用于Python的 pycairo (1.15.4)的最新版本3.6.它以轮包形式分发,因此您应该毫不费力地安装它.

You can try the Unofficial Windows Binaries for Python Extension Packages web site. You can find the last version of pycairo (1.15.4) for Python 3.6. It is distributed as a wheel package so you should install it with no pain.

对于Windows开发人员来说,该网站是众所周知的替代方法.

This web site is a well known alternative for Windows developers.

要安装,请尝试:

pip install https://download.lfd.uci.edu/pythonlibs/gjr6o2id/pycairo-1.15.4-cp36-cp36m-win_amd64.whl

或下载滚轮,然后按以下步骤安装:

Or download the wheel, and install as follow:

pip install pycairo-1.15.4-cp36-cp36m-win_amd64.whl

如果您确实要从源代码安装,则可以按照

If you really want to install from source, you can follow the guide on the Python Wiki. There is a stand alone Microsoft Visual C++ 14.0.

这篇关于在Windows上安装PyCairo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆