5/19/2019»»Sunday

How To Install Pycairo Windows

5/19/2019
    64 - Comments
How To Install Pycairo Windows Rating: 9,4/10 8929 votes

How To Install Pycairo. Download Windows x86 web-based installer; Download Windows x86 executable installer. To install PyCairo in your home directory you. Conda install. Linux-64 v1.17.1; win-32 v1.16.3; osx-64 v1.17.1; win-64 v1.17.1. To install this package with conda run: conda install -c conda-forge pycairo.

I spent hours this afternoon trying to find a straightforward tutorial for installing PyCairo on Windows.

The Cairo project itself does not maintain Windows binaries, they must be dowloaded elsehere (e.g. http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/).

The process is also complicated further apparently by the fact that MSVC is apparently not a supported compiler for PyCairo (although the source patch is simple). See this bug report:

Can anyone recommend a tutorial for installing PyCairo on Windows?

Claynoik
ClaynoikClaynoik

6 Answers

You should try windows binary installers from Gohlke repository for pyCairo and py2Cairo.

I never used pyCairo myself but took 4 minutes to install and get my first png example file done.

joaquinjoaquin

Adding the following for completeness - joaquin's answer above provides a simpler route (and Python 3 support).

Please see the following tutorial:

(also hosted at http://hal.elte.hu/~nepusz/development/igraph/tutorial/install.html).

I asked the question above, so that I could answer it myself. Hopefully people in a similar situation in future will find this post :)

While Googling 'pycairo install windows' does give the above link, it is presented below some rather unhelpful pages, and it's also not particularly obvious that igraph documentation will be applicable.

Eventually I got as far as installing PyCairo (from the GNOME link in the question), without Cairo itself. This gave me a DLL import error when I tried to use it. Fortunately, a question relating to this error exists on StackOverflow:

This question discusses the excellent tutorial from Tamas, linked above, which is all I needed to get up and running.

Community
ClaynoikClaynoik

I believe I have installed a copy using the pygtk all-in-one installer and I believe it did Just Work (32b, python2, mind you). They also mention the gnome URL in your post.

XTLXTL

install pygtk all in onehttp://www.pygtk.org/downloads.htmlIt includes pygtk and all its dependencies, including pycairo

Alex V.Alex V.

A simple tutorial:http://digitalpbk.blogspot.com.au/2012/03/installing-pygtk-pypango-and-pycairo-on.html

only 4 steps and worked like a charm.

MattMatt

There is another similar question in StackOverflow: PyCairo - installation on Windows

The accepted answer is simple and practical.

Although the link it provided is outdated (because the version is up now), the idea is great.

I improve that answer to make it more general:

  1. Go to Unofficial Windows Binaries for Python Extension Packages - Pycairo

  2. Download the pycairo‑***.whl file (choose a proper version for your environment).

  3. Go to the folder where you download the .whl file and type pip install pycairo-***.whl. Wait a few seconds and everything would be done.

I have tested this method and it works perfectly.

HansimovHansimov

Not the answer you're looking for? Browse other questions tagged pythonwindowsinstallationcairopycairo or ask your own question.

Join GitHub today

GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.

Sign upWindows New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments

commented May 10, 2017

Will you be able to install pycairo using pip?

Collaborator

commented May 10, 2017

Hopefully eventually :)

To make this work everywhere we will need to be able to build binary wheels for most of the wanted architectures, then upload these to pip.

Member

commented May 10, 2017

I've brought claiming the pycairo package up multiple times on #pypa, but didn't get a response. Either I was too annoying or they are busy with other things. (@dstufft ?)

We could also use the 'cairo' name, but I fear that will lead to confusion and I'd like to avoid it.

Member

commented May 10, 2017

or use pip install https://github.com/pygobject/pycairo/releases/download/v1.13.1/pycairo-1.13.1.tar.gz

commented May 12, 2017
edited

Doesn't work for me.

Member

commented May 13, 2017

hm, for some reason your pip tries ot use setuptools, but pycairo uses distutils. Will have a look, thanks.

added a commit that referenced this issue May 13, 2017

setup.py: support installation with setuptools. See#39
Member

commented May 13, 2017

This should work now: pip install --user git+https://github.com/pygobject/pycairo.git

commented May 13, 2017

Member

commented May 17, 2017

I've filed a request: https://sourceforge.net/p/pypi/support-requests/728/

Member

commented May 21, 2017

New bugfix release is out: pip install https://github.com/pygobject/pycairo/releases/download/v1.13.2/pycairo-1.13.2.tar.gz should work as well now.

added discussion and removed enhancement labels Jul 14, 2017

commented Jul 19, 2017

I'm getting this error:

Member

commented Jul 19, 2017

There is no Windows support yet (besides mingw/msys2), you can try installing wheels from here: http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#pycairo

referenced this issue Jul 19, 2017

Closed

setup.py: Better error message when pkg-config is not found. #60

commented Aug 12, 2017
edited

Hi,
I'm getting this error:

I'm using Mac Sierra. And I've tried already installed Cairo via both fink (which has only Cairo 1.12), and then by macports (which has Cairo 1.14), so I'm not sure which file the build is failing to find.
Thanks!

Member

commented Aug 12, 2017

This is the same error as two comments up.

Member

commented Aug 12, 2017

You are missing pkg-config

commented Aug 12, 2017

Hi Lazka,
Thanks for the response. I did see the similarity in the error message, but it sounded from your response that the problem was that it was Windows issue. I'm not clear what the issue (and solution) would be for Mac users. Any clarification would be appreciated. Thanks!

Member

commented Aug 12, 2017

Ah, sorry, missed that. pkg-config is used by pycairo for finding your cairo library location. If you use macports I think installing the package pkgconfig should help. You can check that everything works by using pkg-config --modversion cairo, which should print out the cairo version.

The next pycairo release should have a better error message than what you got. See #60

commented Aug 12, 2017

Thank you Thank you Thank you Thank you!!

commented Oct 9, 2017

In case there's any interest, I found that it is relatively easy to build a manylinux wheel for pycairo. The build script is at https://gist.github.com/anntzer/a03230f94e6d111ba3abc737d5091b99 -- you essentially just need docker installed, the script should fetch the manylinux build image and run the wheel build.

Member

commented Oct 10, 2017

Thanks

Collaborator

commented Oct 10, 2017

Is the pypi ownership thing still an issue ?

Member

commented Oct 10, 2017

Yes, no progress there.

Collaborator

commented Oct 10, 2017

Will try and poke some people and see what happens.

Member

commented Nov 7, 2017

Thanks @stuaxo

Collaborator

commented Nov 8, 2017

No probs, they really need to put a note on the sourceforge page to use that github repo!

Member

commented Dec 7, 2017

Member

commented Dec 7, 2017

Pycairo tutorial

@stuaxo I've added you as an owner on pypi as well, so losing access doesn't happen again.

Collaborator

commented Dec 8, 2017

Fantastic work :), this re-enables the pycairo usage for all sorts of users.

Great to see a new version on pypi after 7 years (!).

commented Jan 28, 2018

I needed to
apt-get install python-dev
prior to
pip install pycairo

commented Mar 13, 2018

Having trouble making this work in a (mini)conda virtual environment.

Running Arch linux. I have libxcb installed, and have checked that /usr/include/xcb/xcb.h
does exist.

Works fine at system level.. any ideas?

Member

commented Mar 13, 2018

Weird, afaik /usr/include should be a default search path of your compiler.

export CFLAGS='-I/usr/include $CFLAGS' maybe?

commented Mar 13, 2018

Yeah - that's what I thought! Modifying CFLAGS stopped that error 😄, but immediately hit another one 😢:

I'm not sure where to start interpreting this one..

Member

commented Mar 13, 2018

hm, no idea, I've never used mini/anaconda. Maybe try recreating that environment?

commented Mar 13, 2018

Just tried on a fresh environment and it worked.. odd. Thanks for the thoughts!

commented Mar 28, 2018

On mac, ensure the cairo package is installed (brew install cairo) before attempting to install via pip

commented May 24, 2018
edited

While installing pycairo as a dependency, I needed to run
sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev
before I could get
pip install pycairo to run.
It threw a Package cairo was not found in the pkg-config search path.
Ref

Collaborator

commented May 24, 2018

This will be the case - on Linux and OSX pycairo gives you bindings to the installed version of the cairo library.
On Windows things are different, so we bring our our own version.

The docs could probably be improved, by including an install section for different operating systems.

Member

commented May 24, 2018

I've added some code in pygobject to produce a more helpful error message: https://gitlab.gnome.org/GNOME/pygobject/commit/71eadb88fe75bfda66d449f46cde4b1eb958e4f4

Maybe we should add something similar here.

Collaborator

commented May 24, 2018
edited

Very nice :)

On mac it gets tricky as there can be homebrew or macports.. (or often, when people are new and trying things you come across a system with both).

Lee Gun memiliki sifat yang dingin, memiliki seorang pacar yang bekerja sebagai seorang penari. Nonton drama korea fated to love you. Kim Mi Young merupakan seorang wanita yang bekerja sebagai sekretaris di sebuah kantor hukum. Suatu hari mereka berdua menghabiskan malam dengan mabuk bersama dan menginap di hotel berdua.

I've got a really ancient script in shoebot that you can probably grab the names of the cairo packages from -
https://github.com/shoebot/shoebot/blob/master/install/install_dependencies.sh#L13

referenced this issue May 25, 2018

Closed

Problems while installing (PyGTK) #74

commented Jun 6, 2018

Hi, I do have another error here:

commented Jul 4, 2018

I just reset my Mac's python to the Homebrew latest AND also tried using a virtualenv, but no matter what I get a similar error to @DrUlysses:

Hombrew

virtualenv:

I guess what I'm saying is it appears the pycairo install issue on Mac is not necessarily dependent on environmental issues.

commented Jul 9, 2018

brew install cairo worked for me

commented Jul 23, 2018

this is my 64-bit pc. i tried to install pycairo using msys/mingw.
what should i do now?
thanks!!

commented Jan 15, 2019

Hello all, I wanted to install pycairo but I couldn't manage to, is there anyone who knows what this error message is about? Akvis sketch serial keygen.

Command '/usr/bin/python -u -c 'import setuptools, tokenize;__file__='/private/var/folders/c7/c29gh98s2nj3_s7254frwz5h0000gn/T/pip-req-build-DYzaKm/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))' install --record /private/var/folders/c7/c29gh98s2nj3_s7254frwz5h0000gn/T/pip-record-wgdSi1/install-record.txt --single-version-externally-managed --compile --user --prefix=' failed with error code 1 in /private/var/folders/c7/c29gh98s2nj3_s7254frwz5h0000gn/T/pip-req-build-DYzaKm/

Collaborator

commented Jan 15, 2019

Hi @alfalimawhiskey
Which operating system are you using ?

Cheers
S

commented Jan 15, 2019

macOS High Sierra v10.13.6 @stuaxo

commented Jan 16, 2019
edited

Same problem here

Here's all output:

Notice that 'pkg-config' not found.
If your have the same problem with me, do brew install pkg-config and, problem solved.

commented Jan 16, 2019
edited

First I installed homebrew, then pkg-config, and then installed pycairo using $ brew install python cairo, worked for me. I installed using $ pip3 install pycairo just to make sure and it is all good. Thanks a lot. @45gfg9

Pycairo Install

Collaborator

commented Jan 16, 2019

Cheers, that saved me getting the mac working, I wasn't sure if you were also using brew.

referenced this issue Feb 17, 2019

Open

Installation issue: 'Failed building wheel for pycairo' #121

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment