Installing PyGtk in virtualenv

前端 未结 5 1636
醉梦人生
醉梦人生 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:23

    I did this

    sudo apt-get install python-gtk2

    I found that it was already installed upon some investigation, i found out that when I create a virtual environment, it was missing some links so I came across this post: Virtualenv on Ubuntu with no site-packages.

    I read it and tailored the commands provided to my setup as follows:

    1. First I changed into my virtualenv and activated it by

      source bin/activate
      
    2. Then I changed into the lib/python2.7 folder inside my virtualenv:

      cd lib/python2.7
      
    3. I then executed the following commands.

      $ ln -s /usr/lib/python2.7/dist-packages/cairo/
      $ ln -s /usr/lib/python2.7/dist-packages/pygtk.py
      $ ln -s /usr/lib/python2.7/dist-packages/pygtk.pth
      $ ln -s /usr/lib/python2.7/dist-packages/gtk-2.0/
      
    4. Finally, to check I typed 'python', and executed:

      >>> import pygtk
      

      It gave me no error, and therefore I knew its now available in my virtual env.

    I'm using Ubuntu 14.04 (64-bit) on an intel Core i5.

提交回复
热议问题