Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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.
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.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.