LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-11-2008, 03:27 AM   #1
Yawgm0th
LQ Newbie
 
Registered: Jul 2003
Posts: 14

Rep: Reputation: 0
GTK & Python Problems in Slackware 12


I've been trying to use zenmap, the graphical front-end to nmap, to see how it worked. When I run it, I get the following:
Code:
  File "/usr/local/bin/zenmap", line 60, in excepthook
    import gtk
ImportError: No module named gtk

Original exception was:
Traceback (most recent call last):
  File "/usr/local/bin/zenmap", line 151, in <module>
    app.run()
  File "/usr/local/lib/python2.5/site-packages/zenmapGUI/App.py", line 96, in run
    self.__run_gui()
  File "/usr/local/lib/python2.5/site-packages/zenmapGUI/App.py", line 100, in __run_gui
    import gtk
ImportError: No module named gtk
After some googling and searching here, the best I can come up with is that Python doesn't recognize GTK properly.
Code:
>>> ImportError: No module named gtk
  File "<stdin>", line 1
    ImportError: No module named gtk
               ^
SyntaxError: invalid syntax
This seems to confirm it. However, I have a bunch of other programs which AFAIK are using Python, GTK, and/or PyGTK. Zenmap is the only app I've had thus far with serious issues. Nmap does work fine, for the record.
After looking at some of the search results, I decided to try to install GTK. PyGTK and Python seem to be installed properly.

I dl'ed GTK 2.12.6, which when I look now, does not seem to be the latest. But it's pretty close, and I don't think zenmap or Python need newer. I ran ./configure as a non-root, and that works. But the make (still non-root) fails. It gives this:

Code:
collect2: ld returned 1 exit status
make[4]: *** [gtk-query-immodules-2.0] Error 1
make[4]: Leaving directory `/home/ptilsen/Applications/gtk+-2.12.6/gtk+-2.12.6/gtk'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/ptilsen/Applications/gtk+-2.12.6/gtk+-2.12.6/gtk'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/ptilsen/Applications/gtk+-2.12.6/gtk+-2.12.6/gtk'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ptilsen/Applications/gtk+-2.12.6/gtk+-2.12.6'
make: *** [all] Error 2
I read in one of the results I've found the putting the correct gtk-2.0 folder in /usr/lib/python2.5/sitepackages/gtk-2.0 might fix it, but I don't know how to get that folder and/or the files in it. Aside from that, I'm out of ideas at this point.

Anyone have any ideas?
 
Old 04-11-2008, 05:49 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
you must install pygtk
 
Old 04-11-2008, 11:00 AM   #3
Yawgm0th
LQ Newbie
 
Registered: Jul 2003
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Yawgm0th
PyGTK and Python seem to be installed properly
I've already installed PyGTK. Just for kicks, I installed it again. Here's what the configure told me when it was done:

Code:
The following modules will be built:

atk
pango
pangocairo
gtk with 2.10 API
gtk.glade
gtk.unixprint
 
Old 04-11-2008, 12:59 PM   #4
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
This error:

Code:
ImportError: No module named gtk
is given by python. It's telling you that it found no module to interface with gtk ... this means pygtk is not installed (properly).

I just tried installing and running zenmap just to see if there would be problems, and there was no problem. Just note that you also have to install sqlite and pysqlite. That's what I did not have installed. My python, gtk and nmap are the ones that came with Slackware, and pygtk is version 2.10.6, sqlite version is 3.4.2, and pysqlite is 2.4.1. I can run zenmap just fine without any errors.
 
Old 04-11-2008, 08:28 PM   #5
Yawgm0th
LQ Newbie
 
Registered: Jul 2003
Posts: 14

Original Poster
Rep: Reputation: 0
Your slackware came with nmap? I must not have selected it when I installed Slackware, because I had to install nmap myself.

How can I troubleshoot pygtk? The install did not come up with any errors, so I'm not really sure what to do. What can I do to check if it installed properly?

I believe I installed sqlite and pysqlite, but I'll try again. I'm guessing it won't matter since the issue is with pygtk.

Last edited by Yawgm0th; 04-12-2008 at 02:39 PM.
 
Old 04-12-2008, 04:45 AM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Have you tried the Slackbuilds ? You could use all the Slackbuilds which is bound to work.

http://slackbuilds.org/repository/
 
Old 04-12-2008, 04:51 PM   #7
Yawgm0th
LQ Newbie
 
Registered: Jul 2003
Posts: 14

Original Poster
Rep: Reputation: 0
I tried the slackbuilds version, and just like with building from source, the install threw up no errors whatsoever. But I still cannot import GTK. I figured out that there needs to be file named gtk.py in /usr/lib/python2.5 or it will not find it. Between the source from the repository and the source from the gnome site, there was no file called gtk.py, and therefore it was not getting installed. Thinking it would not work since it was a dumb idea, I copied over pygtk.py and renamed it to gtk.py, and it actually worked.

I no longer receive the GTK import error. Instead, I received the same error for gobjects, proprtyhelper, constants, and dsextras, all of which were py files. I had already installed pygobject -- again, with no errors -- and even tried to do the setup.py for it instead of the normal make install. It threw no errors, but necessary files were not put in the usr/lib/python2.5/site-packages/gtk-2.0/. So I copied each files over (they were all in the extracted pygobject folder from when I installed it) to the directory, and one by one it got rid of the importerrors. Now, when I run zenmap, I get this:


Code:
Traceback (most recent call last):
  File "/usr/local/bin/zenmap", line 151, in <module>
    app.run()
  File "/usr/local/lib/python2.5/site-packages/zenmapGUI/App.py", line 96, in run
    self.__run_gui()
  File "/usr/local/lib/python2.5/site-packages/zenmapGUI/App.py", line 121, in __run_gui
    gtk.main()
AttributeError: 'module' object has no attribute 'main'
Since I don't have the real gtk.py, I'm assuming that it's actually getting to the point at which it tries to use gtk, but of course it can't since I don't have the real gtk.py file. I deleted the fake gtk.py, and it reverted back to the same ImportError message. Why didn't this file get installed?

I must be doing something, very, very wrong here when I've been trying to install/update these libraries, because it's obviously not working right, regardless of the lack of any error messages. I can either do the pygtk.SlackBuild from the Slackware repository or compile and install the pygtk source from pygtk.org, and both will install without error messages. Even the gobject library did not install properly, as I discovered. When I was trying to install just plain GTK, that installation didn't work. I'm fairly new at this, so correct me if I'm doing this wrong.

To install from source, I browse to the directory in a terminal as myself. I run ./configure. If it completes without error messages, I do make. If that completes without error messages, I type su and go into root. Then, I type make install, and it installs. I've managed to get about a dozen other programs, some with GUIs, some with GUI front ends, and some CLIs, installed and working by doing this since I started slackware. Zenmap, or rather the libraries upon which it depends, seem to be the only exception to this. Since it works fine for you on Slacwkare 12, I've got to assume this is operator error.
 
Old 04-12-2008, 06:12 PM   #8
Yawgm0th
LQ Newbie
 
Registered: Jul 2003
Posts: 14

Original Poster
Rep: Reputation: 0
I got zenmap working, and I figured out at least part of what I was doing wrong.

I still don't know why compiling from source with the method described above didn't work, but I did figure out how to do the slackbuilds method. Doing that, I was able to get pysqlite installed properly without issues.

I ended up having to manually copy the gtk-2.0 folder and some of it's contents to /usr/lib/python2.5/site-packages/ to get it working, but once I did it worked like a charm. It as well as some of the other programs were installing to /usr/local/lib/ instead of /usr/lib. I'm not sure it this is expected or needed, but for most of the missing modules, copying the folders or files in there to the corresponding folder in /usr/lib did the trick.

So if you have any tips on things I can not do wrong in the future, I'm all ears. Otherwise, thanks for your help. I got it working due to the slackbuilds repository.
 
Old 04-13-2008, 03:39 AM   #9
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Yes, usually you should install all libraries to '/usr/lib' to avoid these kind of problems. There are ways around this sometimes, but I've found they don't always work.

When you configure libraries written in C or C++ run './configure --prefix=/usr' that'll install them in '/usr/lib'. For python libraries, this is not necessary, all of them will install in '/usr/lib/python2.5/site-packages/' anyway.
 
Old 04-07-2009, 07:28 PM   #10
df508462
LQ Newbie
 
Registered: Mar 2009
Distribution: Slackware
Posts: 7

Rep: Reputation: 1
Thumbs up

Thanks very much for the information in this thread. I was able to get nmap and zenmap working on my Slackware 12.2 by following the steps in the thread.

Dennis
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
python+GTK+Compiz tpariel Linux - Software 1 01-20-2011 03:42 PM
Getting GTK to work with python crazyjimbo Programming 4 11-27-2006 12:14 PM
LXer: How to use GTK+ in C and a C# Python comparison LXer Syndicated Linux News 0 01-12-2006 12:31 PM
GTK Themes Not Loading & Causing Problems MoghNX01 SUSE / openSUSE 3 02-12-2005 02:20 AM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 12:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration