Installing PyGtk in virtualenv

前端 未结 5 1631
醉梦人生
醉梦人生 2020-12-08 18:35

So I am trying to run a simple matplotlib example in my virtualenv (in the console). Here\'s the code:

import matplotlib
matplotlib.use(\'GTKAgg\')
import ma         


        
5条回答
  •  生来不讨喜
    2020-12-08 19:21

    The trick is to manually set the correct paths and then run configure inside the virtualenv. This is quite basic, but it worked for me.

    Install python-config in the virtual env and link it to python2.7-config:

    pip install config
    ln -s /home/PATH/TO/VIRT/bin/python-config /home/PATH/TO/VIRT/bin/python2.7-config
    

    Install cairo in the virtual env:

    wget http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2
    tar -xf py2cairo-1.10.0.tar.bz2
    cd py2cairo-1.10.0
    ./waf configure --prefix=/home/PATH/TO/VIRT/
    ./waf build
    ./waf install
    

    Install PyGTK

    wget http://pypi.python.org/packages/source/P/PyGTK/pygtk-2.24.0.tar.bz2
    tar -xf pygtk-2.24.0.tar.bz2
    cd pygtk-2.24.0
    export PKG_CONFIG_PATH=/home/PATH/TO/VIRT/lib/pkgconfig
    ./configure --prefix=/home/PATH/TO/VIRT/
    make 
    make install
    

    And that should do it. Just replace PATH/TO/VIRT/ with your own path. I'm sure someone could assist on adding the path to virtualenvwrapper?

提交回复
热议问题