K
Kelly, Brian
I have both 2.4 and 2.5 interpreters installed on a linux box. The
PythonPath is set to :
PYTHONPATH=/usr/lib64/portage/pym:/prod/bacula/local/lib64/python2.4/site-pa
ckages:/prod/bacula/local/lib/python2.4/site-packages
My main script is getting called like so:
python2.4 cleanup.py wrkstnbs
The imports statements in cleanup.py are as follows:
import os,sys
print sys.path
from datetime import datetime
from optparse import OptionParser # used for parsing parameters
from bacula_conf import * # used for connecting to our
databases, etc.
from registration_cleanup \
import RegistrationCleanup # used for interacting w/
registration db (sql1)
# and configuration database
(genunix)
import directory_cleanup as fclean # file cleanup.
One of the scripts being imported from bacula_conf is called
purge_client.py.
It has the following imports:
import sys
import MySQLdb
Everytime I run "python2.4 cleanup.py wrkstnbs" I get the following error:
Traceback (most recent call last):
File "purge_client.py", line 22, in <module>
import MySQLdb
File
"/prod/bacula/local/lib64/python2.4/site-packages/MySQLdb/__init__.py", line
27, in <module>
import _mysql
ImportError: /prod/bacula/local/lib64/python2.4/site-packages/_mysql.so:
undefined symbol: Py_InitModule4
If I print sys.path of both the calling script and the imported module I get
the following sys.path from cleanup.py:
['/prod/bacula/local/tools/bacula_conf/maintenance',
'/usr/lib64/portage/pym',
'/prod/bacula/local/lib64/python2.4/site-packages',
'/prod/bacula/local/lib/python2.4/site-packages', '/usr/lib/python24.zip',
'/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload',
'/usr/lib/portage/pym', '/usr/lib64/python2.4/site-packages',
'/usr/lib/python2.4/site-packages']
However the sys.path printed by the called module purge_client.py displays
as such:
['/prod/bacula/local/tools/bacula_conf/maintenance',
'/usr/lib64/portage/pym',
'/prod/bacula/local/lib64/python2.4/site-packages',
'/prod/bacula/local/lib/python2.4/site-packages', '/usr/lib64/python25.zip',
'/usr/lib64/python2.5', '/usr/lib64/python2.5/plat-linux2',
'/usr/lib64/python2.5/lib-tk', '/usr/lib64/python2.5/lib-dynload',
'/usr/lib64/python2.5/site-packages']
If I call purge_client.py like so: python2.4 purge_client.py wrkstnbs the
sys.path is:
['/prod/bacula/local/tools/bacula_conf/maintenance',
'/usr/lib64/portage/pym',
'/prod/bacula/local/lib64/python2.4/site-packages',
'/prod/bacula/local/lib/python2.4/site-packages', '/usr/lib/python24.zip',
'/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload',
'/usr/lib/portage/pym', '/usr/lib64/python2.4/site-packages',
'/usr/lib/python2.4/site-packages']
Can anyone explain why purge_client.py has a different sys.path when
imported from another script? At this point I'm quite puzzled and would like
to continue using the 2.4 interpreter for the time being.
Thanks,
Brian Kelly
PythonPath is set to :
PYTHONPATH=/usr/lib64/portage/pym:/prod/bacula/local/lib64/python2.4/site-pa
ckages:/prod/bacula/local/lib/python2.4/site-packages
My main script is getting called like so:
python2.4 cleanup.py wrkstnbs
The imports statements in cleanup.py are as follows:
import os,sys
print sys.path
from datetime import datetime
from optparse import OptionParser # used for parsing parameters
from bacula_conf import * # used for connecting to our
databases, etc.
from registration_cleanup \
import RegistrationCleanup # used for interacting w/
registration db (sql1)
# and configuration database
(genunix)
import directory_cleanup as fclean # file cleanup.
One of the scripts being imported from bacula_conf is called
purge_client.py.
It has the following imports:
import sys
import MySQLdb
Everytime I run "python2.4 cleanup.py wrkstnbs" I get the following error:
Traceback (most recent call last):
File "purge_client.py", line 22, in <module>
import MySQLdb
File
"/prod/bacula/local/lib64/python2.4/site-packages/MySQLdb/__init__.py", line
27, in <module>
import _mysql
ImportError: /prod/bacula/local/lib64/python2.4/site-packages/_mysql.so:
undefined symbol: Py_InitModule4
If I print sys.path of both the calling script and the imported module I get
the following sys.path from cleanup.py:
['/prod/bacula/local/tools/bacula_conf/maintenance',
'/usr/lib64/portage/pym',
'/prod/bacula/local/lib64/python2.4/site-packages',
'/prod/bacula/local/lib/python2.4/site-packages', '/usr/lib/python24.zip',
'/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload',
'/usr/lib/portage/pym', '/usr/lib64/python2.4/site-packages',
'/usr/lib/python2.4/site-packages']
However the sys.path printed by the called module purge_client.py displays
as such:
['/prod/bacula/local/tools/bacula_conf/maintenance',
'/usr/lib64/portage/pym',
'/prod/bacula/local/lib64/python2.4/site-packages',
'/prod/bacula/local/lib/python2.4/site-packages', '/usr/lib64/python25.zip',
'/usr/lib64/python2.5', '/usr/lib64/python2.5/plat-linux2',
'/usr/lib64/python2.5/lib-tk', '/usr/lib64/python2.5/lib-dynload',
'/usr/lib64/python2.5/site-packages']
If I call purge_client.py like so: python2.4 purge_client.py wrkstnbs the
sys.path is:
['/prod/bacula/local/tools/bacula_conf/maintenance',
'/usr/lib64/portage/pym',
'/prod/bacula/local/lib64/python2.4/site-packages',
'/prod/bacula/local/lib/python2.4/site-packages', '/usr/lib/python24.zip',
'/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload',
'/usr/lib/portage/pym', '/usr/lib64/python2.4/site-packages',
'/usr/lib/python2.4/site-packages']
Can anyone explain why purge_client.py has a different sys.path when
imported from another script? At this point I'm quite puzzled and would like
to continue using the 2.4 interpreter for the time being.
Thanks,
Brian Kelly