Reputation: 1598
I am trying to generate HTML documentation using pydoc. The project is divided in several subfolders, all of them containing __init__.py
files.
The content of __init__.py
in my main folder is as follows:
import sys
sys.path.insert(1, '.')
I can run the application without any problems. Files within subfolders can see files in the main folder, and all imported modules run just fine.
However, pydoc is giving me problems. If I try to use it on files within subfolders, they won't see the files in the main folder.
Also, installed modules are not seen. For example, running pydoc -w
on my ftp_operations file (located in the main folder) says it cannot find Paramiko, which runs just fine in the application.
I have seen some similar questions but most of the answers refer to adding the __init__.py
files, which I already have. I tried pdoc3 as well, with the same results. What am I doing wrong? I am using Python 3.7.
Thanks in advance!
Upvotes: 3
Views: 1813
Reputation: 31
Are you using a virtual environment? pydoc
by default will call a system Python executable (which may be unable to locate your modules) even if the command is called from within a virtual environment.
If you wish to use a virtual environment to generate docs with pydoc, you need to call python -m pydoc [OPTIONS]
to ensure that the correct python
executable is called. Alternatively, you can edit the shebang line of the pydoc
script to refer to your environment.
For example, the pydoc
script should look something like:
#!/some/system/path/bin/python3.7
import pydoc
if __name__ == '__main__':
pydoc.cli()
and would be changed to look like:
#!/usr/bin/env python
import pydoc
if __name__ == '__main__':
pydoc.cli()
Upvotes: 3