Hi All

Firstly i am new to pythong and I am stuck with the following problem
dont really know whether it has been posted previously in the mailing list(
pardon me if its so )

I have written (found in the net ) a small program to list the rpms in the
linux box

------------Starts here ------------
#!/usr/bin/python2.5
import rpm
ts=rpm.TransactionSet()
mi=ts.dbMatch()
for h in mi:
 print h['name']

--------Ends Here-----------------

It executes fine in the  python shell, but the problem is in when i execute
as a  python script  i get the following error

DCA-TestMachine:~/python_scripts # python2.5 -v rpmqa.py
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/local/lib/python2.5/site.pyc matches /usr/local/lib/python2.5/site.py
import site # precompiled from /usr/local/lib/python2.5/site.pyc
# /usr/local/lib/python2.5/os.pyc matches /usr/local/lib/python2.5/os.py
import os # precompiled from /usr/local/lib/python2.5/os.pyc
import posix # builtin
# /usr/local/lib/python2.5/posixpath.pyc matches
/usr/local/lib/python2.5/posixpath.py
import posixpath # precompiled from /usr/local/lib/python2.5/posixpath.pyc
# /usr/local/lib/python2.5/stat.pyc matches /usr/local/lib/python2.5/stat.py
import stat # precompiled from /usr/local/lib/python2.5/stat.pyc
# /usr/local/lib/python2.5/UserDict.pyc matches
/usr/local/lib/python2.5/UserDict.py
import UserDict # precompiled from /usr/local/lib/python2.5/UserDict.pyc
# /usr/local/lib/python2.5/copy_reg.pyc matches
/usr/local/lib/python2.5/copy_reg.py
import copy_reg # precompiled from /usr/local/lib/python2.5/copy_reg.pyc
# /usr/local/lib/python2.5/types.pyc matches
/usr/local/lib/python2.5/types.py
import types # precompiled from /usr/local/lib/python2.5/types.pyc
import _types # builtin
# /usr/local/lib/python2.5/warnings.pyc matches
/usr/local/lib/python2.5/warnings.py
import warnings # precompiled from /usr/local/lib/python2.5/warnings.pyc
# /usr/local/lib/python2.5/linecache.pyc matches
/usr/local/lib/python2.5/linecache.py
import linecache # precompiled from /usr/local/lib/python2.5/linecache.pyc
import encodings # directory /usr/local/lib/python2.5/encodings
# /usr/local/lib/python2.5/encodings/__init__.pyc matches
/usr/local/lib/python2.5/encodings/__init__.py
import encodings # precompiled from
/usr/local/lib/python2.5/encodings/__init__.pyc
# /usr/local/lib/python2.5/codecs.pyc matches
/usr/local/lib/python2.5/codecs.py
import codecs # precompiled from /usr/local/lib/python2.5/codecs.pyc
import _codecs # builtin
# /usr/local/lib/python2.5/encodings/aliases.pyc matches
/usr/local/lib/python2.5/encodings/aliases.py
import encodings.aliases # precompiled from
/usr/local/lib/python2.5/encodings/aliases.pyc
# /usr/local/lib/python2.5/encodings/utf_8.pyc matches
/usr/local/lib/python2.5/encodings/utf_8.py
import encodings.utf_8 # precompiled from
/usr/local/lib/python2.5/encodings/utf_8.pyc
Python 2.5.1 (r251:54863, Jun 21 2007, 10:46:46)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
# /root/python_scripts/rpm.pyc matches /root/python_scripts/rpm.py
import rpm # precompiled from /root/python_scripts/rpm.pyc
Traceback (most recent call last):
 File "rpmqa.py", line 1, in <module>
   import rpm
 File "/root/python_scripts/rpm.py", line 10, in <module>
   main()
 File "/root/python_scripts/rpm.py", line 3, in main
   tss= rpm.TransactionSet()
AttributeError: 'module' object has no attribute 'TransactionSet'
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] site
# cleanup[1] encodings
# cleanup[1] _codecs
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] encodings.utf_8
# cleanup[1] codecs
# cleanup[1] types
# cleanup[1] _types
# cleanup[1] signal
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] os.path
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
[7359 refs]
# cleanup ints: 7 unfreed ints in 1 out of 7 blocks
# cleanup floats


I dont know what path I should set the PYTHONHOME PYTHONPATH .etc..
variables


Thanks in advance for your help
--
Regards
Subramanyam
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to