What is an import and where is it on the hard disk
Jeff Shannon
jeff at ccvcorp.com
Tue Apr 23 13:49:42 EDT 2002
In article <3CC4A51A.A7D770ED at sympatico.ca>,
francis049 at sympatico.ca says...
> I receive an error message like :
>
> Traceback (innermost last) :
> File : /usr/sbin/up2date, line 9, in ?
> import rpm
> Import error : No module named rpm
>
>
> Anyone can tell me why is this error happening and give me some details
> ... please ?
As Geoff Gerrietts said, it's hard to tell exactly *why* this
happened when there's no detail given about when or where this
error occurred.
For an explanation of what import is, and what it means, read the
Python tutorial chapter on modules, here:
http://www.python.org/doc/current/tut/node8.html
The error you got implies that there is no rpm.py file in any of
the directories in your sys.path. This could be because the file
is missing, or it could be because your path is bad.
Red Hat uses Python 1.5.2 for a number of its system utilities,
and expects to be able to access that version from
/usr/bin/python. Perhaps the most likely scenario here, is that
you've upgraded Python so that /usr/bin/python is now Python 2.x,
and the new version of Python doesn't search the old version's
site-lib for Red Hat's tools. (Some of those tools are broken
under 2.x anyhow...) You can verify this as Geoff suggested, by
checking the version of python with this shell command:
$ python -c "import sys; print sys.version"
If this does not show version 1.5.2, then you'll want to remove
the current version of python, restore 1.5.2 (which may be as
simple as deleting /usr/bin/python and recreating it as a link to
/usr/bin/python15, or may require reinstalling the RPM), and then
installing the new version of python from Red Hat's latest
python2 RPMs. This will create the new version as
/usr/bin/python2, and both can coexist (though you'll need to run
your scripts as 'python2 myscript.py').
--
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list