This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pydoc can't find module in current dir
Type: enhancement Stage:
Components: Demos and Tools Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ping Nosy List: fdrake, ping, skip.montanaro
Priority: normal Keywords:

Created on 2001-03-20 21:42 by skip.montanaro, last changed 2022-04-10 16:03 by admin. This issue is now closed.

Messages (4)
msg3980 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2001-03-20 21:42
On my linux system pydoc doesn't seem able to find
modules in the current directory unless I set the
PYTHONPATH environment variable, including ".":

    % pydoc OO_Model
    No Python documentation found for 'OO_Model'.
    beluga:lib% PYTHONPATH=. pydoc OO_Model

    Python Library Documentation: module OO_Model
    ...

I examined the output of pydoc.pathdirs().  Even
without setting PYTHONPATH the directory containing the
OO_Model module is in the output (second directory):

    % python
    Python 2.1b1 (#1, Mar 12 2001, 16:13:37) 
    [GCC 2.95.3 19991030 (prerelease)] on linux2
    Type "copyright", "credits" or "license" for more
    information.
    >>> import pydoc
    >>> pydoc.pathdirs()
    ['/usr/local/lib/automatrix/python',
     '/home/skip/src/tttech/lib',
     '/usr/local/lib/python2.1',
     '/usr/local/lib/python2.1/plat-linux2',
     '/usr/local/lib/python2.1/lib-tk',
     '/usr/local/lib/python2.1/lib-dynload',
     '/usr/local/lib/python2.1/site-packages',
     '/home/skip/src/Zope/lib/python']

Seems like a bug to me.

msg3981 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-03-21 06:00
Logged In: YES 
user_id=3066

This ia a pydoc issue; sys.path for a script includes the
script dir but not (necessarily) the current dir.

Assigned to Ping.
msg3982 - (view) Author: Ka-Ping Yee (ping) * (Python committer) Date: 2001-03-26 23:37
Logged In: YES 
user_id=45338

Python itself is inconsistent in this regard (as Fred
rightly points out).  For now, the pydoc that made it
into 2.1b2 adds '.' to the path when run as a script;
in future it should probably also *remove* the script
directory from sys.path (when the script directory is
not the same as the current dir) for good consistency
with running python and importing pydoc interactively.
msg3983 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-03-28 14:52
Logged In: YES 
user_id=3066

I'd describe this as "Python does the right thing" -- pydoc is then overloading the semantics of sys.path.  It sounds like the internals of pydoc should receive a search path to use -- the startup code for pydoc can then compute that based on sys.path, removing it's own directory from it and adding anything more as appropriate.
History
Date User Action Args
2022-04-10 16:03:53adminsetgithub: 34203
2001-03-20 21:42:38skip.montanarocreate