I don't know if this is normal behavior, but importing gtk causes
sys.path to be modified. This holds for both pygtk-2.4.1 and
pygtk-2.6.x. The path the python module being run is getting loaded
into the first postion of sys.path. This happens normally when python
is run on a module, but gtk is inserting *another* one.
Why the extra one? This is particularly problematic for pychecker,
which modifies the path so that its own internal modules are exposed
last in sys.path. Some debugging reveals that its the _gtk extension
module that causes the change, but I was not able to determine where the
change is being made.
To demonstrate, this code:
# jnk.py
import sys
print "sys.path before:"
print sys.path
print "sys.argv before:"
print sys.argv
print
import gtk
print "sys.path after:"
print sys.path
print "sys.argv after:"
print sys.argv
# end
results in:
localhost:tmp$ python `pwd`/jnk.py
sys.path before:
['/home/jcollins/tmp', '/opt/local/lib/python24.zip',
'/opt/local/lib/python2.4', '/opt/local/lib/python2.4/plat-linux2',
'/opt/local/lib/python2.4/lib-tk',
'/opt/local/lib/python2.4/lib-dynload',
'/opt/local/lib/python2.4/site-packages',
'/opt/local/lib/python2.4/site-packages/Numeric',
'/opt/local/lib/python2.4/site-packages/gtk-2.0',
'/opt/local/lib/python2.4/site-packages/vtk_python']
sys.argv before:
['/home/jcollins/tmp/jnk.py']
sys.path after:
['/home/jcollins/tmp', '/home/jcollins/tmp',
'/opt/local/lib/python24.zip', '/opt/local/lib/python2.4',
'/opt/local/lib/python2.4/plat-linux2',
'/opt/local/lib/python2.4/lib-tk',
'/opt/local/lib/python2.4/lib-dynload',
'/opt/local/lib/python2.4/site-packages',
'/opt/local/lib/python2.4/site-packages/Numeric',
'/opt/local/lib/python2.4/site-packages/gtk-2.0',
'/opt/local/lib/python2.4/site-packages/vtk_python']
sys.argv after:
['/home/jcollins/tmp/jnk.py']
Running pychecker on the same:
localhost:tmp$ pychecker jnk.py
Processing jnk...
sys.path before:
['', '/opt/local/lib/python24.zip', '/opt/local/lib/python2.4',
'/opt/local/lib/python2.4/plat-linux2',
'/opt/local/lib/python2.4/lib-tk',
'/opt/local/lib/python2.4/lib-dynload',
'/opt/local/lib/python2.4/site-packages',
'/opt/local/lib/python2.4/site-packages/Numeric',
'/opt/local/lib/python2.4/site-packages/gtk-2.0',
'/opt/local/lib/python2.4/site-packages/vtk_python']
sys.argv before:
['/opt/local/lib/python2.4/site-packages/pychecker/checker.py', 'jnk.py']
sys.path after:
['/home/opt/local/lib/python2.4/site-packages/pychecker', '',
'/opt/local/lib/python24.zip', '/opt/local/lib/python2.4',
'/opt/local/lib/python2.4/plat-linux2',
'/opt/local/lib/python2.4/lib-tk',
'/opt/local/lib/python2.4/lib-dynload',
'/opt/local/lib/python2.4/site-packages',
'/opt/local/lib/python2.4/site-packages/Numeric',
'/opt/local/lib/python2.4/site-packages/gtk-2.0',
'/opt/local/lib/python2.4/site-packages/vtk_python']
sys.argv after:
['/opt/local/lib/python2.4/site-packages/pychecker/checker.py', 'jnk.py']
ImportError: No module named _gobject
--
-----------------------------------------------------------------
Jeffery D. Collins, Ph.D. Vexcel Corp.
Sr. Engineer 1690 38th St.
Voice: (303)583-0228 Boulder, CO 80301
Fax: (303)583-0246 vexcel.com
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/