Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install pycairo in virtualenv

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!

like image 234
Radu Gheorghiu Avatar asked Jul 15 '12 10:07

Radu Gheorghiu


People also ask

How do I download Pycairo?

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.

How install Pycairo Linux?

Installing Pycairo requires pkg-config and cairo including its headers. Here are some examples on how to install those for some platforms: Ubuntu/Debian: sudo apt install libcairo2-dev pkg-config python3-dev. macOS/Homebrew: brew install cairo pkg-config.

How do I manually install a Python package in Virtualenv?

Option 1 is to unzip the python program into /home/username/tmp - then log into my virtualenv, navigate to that folder and run the setup.py program - assuming that the virtualenv will transfer all relevant files to it's own site-packages folder.

What is Pycairo in Python?

Pycairo is a set of Python 2 & 3 bindings for the cairo graphics library. Since version 1.11. 0 pycairo has moved to GitHub and pycairo and py2cairo have been merged back into one project.

How do I install virtualenv in Python?

Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip. Unix/macOS python3 -m pip install --user virtualenv Windows py -m pip install --user virtualenv Creating a virtual environment¶

How to install PyGObject in virtualenv?

To install PyGObject in virtrualenv, give up with pip. Install PyGObject system-wide (with your package manager or compile it manually). For example, in my case : You might find some helpful infos about system-wide and virtualenv installations and interactions between modules here : I've made vext to automate this.

How do I install a Python package in a virtual environment?

py -m pip install --user virtualenv Creating a virtual environment ¶ venv (for Python 3) and virtualenv (for Python 2) allow you to manage separate package installations for different projects. They essentially allow you to create a “virtual” isolated Python installation and install packages into that virtual installation.

What are virtual environments in Python and how do they work?

They essentially allow you to create a “virtual” isolated Python installation and install packages into that virtual installation. When you switch projects, you can simply create a new virtual environment and not have to worry about breaking the packages installed in the other environments.


2 Answers

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.

pip install cairocffi 

In your code:

import cairocffi as cairo # Enjoy the same API as Pycairo. 

Feedback welcome. (Although the issue tracker might be a better channel than here.)

like image 197
Simon Sapin Avatar answered Sep 22 '22 19:09

Simon Sapin


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:

  1. download, unpack, and cd into the the py2cairo directory
  2. Activate your virtual environment
  3. Follow the standard build procedure

./waf configure --prefix=$VIRTUAL_ENV

./waf build

./waf install

like image 24
tgmauch Avatar answered Sep 23 '22 19:09

tgmauch