views:

38

answers:

1

I've upgraded to Python 2.7 from Python 2.6 on Ubuntu Maverick Meerkat (10.10) and I'm unable to import PyQt4.

austin@gerald:~$ python2.7
Python 2.7.0+ (r27:82500, Sep 15 2010, 18:04:55) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4

I installed both Python 2.7 (python2.7) and PyQt4 (python-qt4) from the Ubuntu repositories. I installed PyQt a while back, but I installed Python 2.7 recently.

If I try Python 2.6 (since it's shipped with Ubuntu, the command is simply python), it works perfectly. Watch:

austin@gerald:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4

I know what the problem is: the PyQt4 modules are accessible by Python 2.6 but not 2.7. My question is, how do I get Python 2.7 to find the PyQt4 module(s)? Help!

Note: sorry if this belongs in Super User, I was just programming when I encountered this problem.

+1  A: 

You should install PyQt4 in the Python 2.7 environment. To do this run

easy_install2.7 PyQt4

If easy_install is not installed you will need to first download and install it by running

python2.7 setup.py install
Evgeny
@Evgeny: excuse me but i want to do one remark , why not pip ? haven't you heard ,"easy_install is dead long live to pip" :)
singularity
Yes, you're right. :) I'm just used to easy_install
Evgeny
That didn't work. When I run "easy_install-2.7 PyQt4" it just says "Reading http://pypi.python.org/simple/PyQt4/Couldn't find index page for 'PyQt4' (maybe misspelled?)Scanning index of all packages (this may take a while)Reading http://pypi.python.org/simple/No local packages or download links found for PyQt4error: Could not find suitable distribution for Requirement.parse('PyQt4')" :( How do I use pip?
UncleNinja