pydoc problem

Stephen C Phillips news at scphillips.co.uk
Wed Jan 15 11:09:42 EST 2003


Hi,
	I am having problems with Pydoc and I do not know if it is a problem
with Pydoc or a problem with the way I am using the import command.  I
have created a minimal package that displays my problem:

bug
|-- __init__.py
|-- bar
|   |-- __init__.py
|   `-- other.py      (imports thing)
 `-- foo
    |-- __init__.py
    |-- base.py       (imports thing)
    `-- thing.py

So I have a package called bug with an empty __init__.py and sub-packages
foo and bar also with empty __init__.py files.  Each python file just
contains one import statement.  They are:

bar.other:
from bug.foo import thing

foo.base:
from bug.foo import thing

foo.thing:
import math

	If I am in the directory containing the bug package and I run 'pydoc -g'
(or 'pydoc2 -g' on my RedHat system) then I get the Tk interface to pydoc.
 I click on the 'bug' package link in the index, then on 'bar', then
'other', then to 'bug.foo.thing'.  If I then go back and go to the 'foo'
package, I can go directly to 'thing' but clicking on 'base' gives this
error:

problem in ./bug/foo/base.pyc - ImportError: cannot import name thing

	If I run pydoc again and go 'bug', then 'foo', then 'base' it works
fine.

	I have read Guido's essay on Python packages and tried looking at the
contents of sys.modules but this is beyond me.  The package I am writing
that exhibited this problem is much larger and works fine at run-time so
the package imports must be correct in some sense, but Pydoc doesn't like
them.
	Can anyone tell me what I am doing wrong?

	Incidentally, I've just looked at the Scientific package, and navigating
through 'site-packages', 'Scientific', 'BSP', 'Console' gives an error
too...

	My system is RedHat 7.3, with the python2-2.2-16 RPM.  My Python version
	is:

Python 2.2 (#1, Apr 12 2002, 15:29:57) [GCC 2.96 20000731 (Red Hat Linux
7.2 2.96-109)] on linux2

Thanks.




More information about the Python-list mailing list