I've tried to install pycairo
in a virtualenv to use in a Django project. I've ran the pip install pycairo==1.10.0
command which finds the package and downloads it unlike other commands like pip install pycairo
, etc. but when starting to install the package it throws an error.
Here's the log:
Downloading/unpacking pycairo==1.10.0
Running setup.py egg_info for package pycairo
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory:
'/home/radu/Desktop/djangos/workout/venv/build/pycairo/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory:
'/home/radu/Desktop/djangos/workout/venv/build/pycairo/setup.py'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in
/home/radu/Desktop/djangos/workout/venv/build/pycairo
Storing complete log in /home/radu/.pip/pip.log
Could you please give me any hints about what to do? Should I try and write a setup.py file for the package and then try to install it? (i'm not sure it's even a solution, i still am trying to figure out what I can do).
Thanks in advance!
If
cairocffi
installation invirtualenv
does not work andpython-dev libffi-dev
are unavailable (ArchLinux) setting environmental variablePKG_CONFIG_PATH=/usr/lib/libffi-3.2.1/include
works.pycairo currently does not support installation through pip/distutils. The project’s install docs instructs to use either waf or autotools.
To use pycairo in a virtualenv, you need to:
--system-site-packages
option or remove thelib/pythonX.Y/no-global-site-packages.txt
file after the fact.cairo
package (the directory containing_cairo.so
). Something like this:Of course 1. has the downside that you will not profit from virtualenv’s isolation from other packages installed system-wide.
Good news, everyone!
I just released cairocffi: http://packages.python.org/cairocffi/
It’s a replacement for pycairo that installs with pip in a virtualenv, runs on Python 2 and 3, as well as PyPy.
In your code:
Feedback welcome. (Although the issue tracker might be a better channel than here.)
Although py2cairo doesn't install nicely using pip, you can still install py2cairo into the virtual environment using the build instructions in the INSTALL file from the distribution.
You will need the cairo-dev/cairo-devel package for you os installed in order to build the package.
Do the following to install into your virtual environment:
./waf configure --prefix=$VIRTUAL_ENV
./waf build
./waf install
If you are using Homebrew you can install the
pycario
(Python 3+) andpy2cario
(Python 2.6-2.7) recipes:brew install pycario
For anyone trying to use pycairo (for Python 2.7) in conjunction with Homebrew and virtualenv
--no-site-packages
... this Worked For Me:brew install py2cairo
Then, find the path where Homebrew installed it to, will be something like:
You want to find the path at the base of those symlinks, something like:
/usr/local/Cellar/py2cairo/1.10.0/lib/python2.7/site-packages
Then create a .pth file in your virtualenv site packages:
echo "/usr/local/Cellar/py2cairo/1.10.0/lib/python2.7/site-packages" > venv/lib/python2.7/site-packages/cairo.pth
(may want to deactivate and re-activate your virtualenv for good luck, not sure)