Skip to content Skip to sidebar Skip to footer

Manually Importing Gtk Fails: Module Not Found

So I would like to execute a python script from command line then and again, and it has to be very quick. Imports in python are slow because the entire sys.path is searched for the

Solution 1:

Importing the compiled __init__.pyc seems to work here, using import_module instead of import_source. However, the import is still notably slow...

# done manually once
file,filename,descr=imp.find_module('gtk')
print file,filename,descr

script:

# script
gtk=imp.load_module('gtk',FILE,FILENAME,DESCRIPTION) # the respective values
# gtk=imp.load_module("gtk",None,"/usr/lib/python2.7/dist-packages/gtk-2.0/gtk",('','',5))
from gtk import gdk

Post a Comment for "Manually Importing Gtk Fails: Module Not Found"