You are not logged in.

#1 2013-09-26 20:55:27

dluco
Member
Registered: 2013-08-30
Posts: 22

[SOLVED] pygtk error - ImportError : No module name 'pygtk'

Hi,
pygtk has not been working (and never has), and I've looked at and tried solutions in other threads, but none have fixed my problem.
This is what I did:

$ python
Python 3.3.2 (default, Sep  6 2013, 09:35:59) 
[GCC 4.8.1 20130725 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'pygtk'
>>> 

I've tried uninstalling pygtk, pygobject, and pycairo, and then reinstalling pygobject, pycairo, then pygtk, as suggested in other threads.

Thank you for any help,
dluco

Last edited by dluco (2013-09-27 03:58:37)

Offline

#2 2013-09-26 21:01:30

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] pygtk error - ImportError : No module name 'pygtk'

pygtk is for python2, not python3.

Offline

#3 2013-09-26 22:24:32

dluco
Member
Registered: 2013-08-30
Posts: 22

Re: [SOLVED] pygtk error - ImportError : No module name 'pygtk'

Got it. Running

$ python2
>>>import pygtk

works just fine.

The reason I was trying to get pygtk to work is because I have a script that needs pygtk. The script starts with

#!/usr/bin/env python

Would changing the header to "python2" work?

Thanks

Offline

#4 2013-09-26 22:35:43

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] pygtk error - ImportError : No module name 'pygtk'

Depends on the script. If it's using pygtk, it most likely is targeting python2 in the first place, so yes, just change "python" to "python2" in the shebang and you should be fine.

Last edited by Scimmia (2013-09-26 22:36:16)

Offline

#5 2013-09-26 22:37:25

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,742

Re: [SOLVED] pygtk error - ImportError : No module name 'pygtk'

dluco wrote:

Got it. Running

$ python2
>>>import pygtk

works just fine.

The reason I was trying to get pygtk to work is because I have a script that needs pygtk. The script starts with

#!/usr/bin/env python

Would changing the header to "python2" work?

Thanks

Almost certainly.  If you want to try it first, launch the script by placing python2 in from of the name, in other words:

ewaller$@$odin ~/devel/python 1008 %./hello uptime
  File "./hello", line 11
    print "Content-type: text/html"
                                  ^
SyntaxError: invalid syntax
ewaller$@$odin ~/devel/python [1]1009 %python2 hello uptime
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title> It's my party</title>
</head>
<body>
<h3>The passed parameters are:</h3>
<br>hello
<br>uptime
<p><h2>Here is the output from the linux command uptime</h2><p>
<pre>
 15:36:00 up 2 days, 18:08,  2 users,  load average: 0.12, 0.20, 0.22 </pre>
</body>
</html>
ewaller$@$odin ~/devel/python 1010 %

BTW, do not ever leave a script like this laying around on a Django server smile


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#6 2013-09-27 00:48:12

dluco
Member
Registered: 2013-08-30
Posts: 22

Re: [SOLVED] pygtk error - ImportError : No module name 'pygtk'

Awesome, works like a charm now. Thanks!

For the record, the problem of pygtk not working was due to the fact that python3 was being used instead of python2.

Going slightly off topic, I was wondering how the majority of arch-users shutdown/reboot their comps. Right now I use

sudo poweroff

which gets tedious after awhile (like now).
To make my life easier, I planned on using a logout script written in python that I use in crunchbang. However, I ran into the pygtk problem (above), and now I have the problem that the script can't successfully logout due to org.freedesktop.ConsoleKit not being provided by any .service files.
I'm sorry if this is too off-topic, and I'll definitely mark this thread as solved in any case.

Offline

#7 2013-09-27 01:05:23

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] pygtk error - ImportError : No module name 'pygtk'

If it's too much typing, why not use an alias like

alias H="systemctl poweroff"

Offline

#8 2013-09-27 03:58:11

dluco
Member
Registered: 2013-08-30
Posts: 22

Re: [SOLVED] pygtk error - ImportError : No module name 'pygtk'

Exactly what I was looking for! Thanks!

Marking tread as solved.

Offline

Board footer

Powered by FluxBB