0

Everytime, I want to access the documentation of libraries that I need for my project, I have to go to their website. Python has the excellent utility called pydoc, but I can only access the documentation of the python standard library functions in pydoc. How do I store/generate/get the documentation for any python library locally and access it via pydoc?

Note: I am not talking about generating the documentation for my own project using pydoc, but accessing the documentation of other projects via the pydoc command as such

pydoc os
pydoc str
pydoc re
pydoc re.search
pydoc re.match

Essentially I want to be able to do

pydoc numpy.pi
pydoc numpy.linspace
3
  • 2
    Above commands work for me. Also tried pydoc3.12 -p 8888 and was able to read docs of installed packages at http://localhost:8888/numpy.html Commented Jul 4 at 21:31
  • @LMC What is your python setup? Are you using a python package manager like Poetry, pipenv ? How does pydoc know where to search for the documentation? Commented Jul 10 at 21:05
  • Pydoc shows docs of installed packages in these directories pip3.12 list -v | awk '{print $3}' | sort -u | grep '^[/]' Commented Jul 10 at 21:12

2 Answers 2

2

The pydoc documentation comes bundled with each Python package, so to have offline access to the documentation via pydoc, you need to install the respective packages. As far as I know, there is no way to obtain the pydoc documentation separately from the packages themselves.

Sign up to request clarification or add additional context in comments.

3 Comments

Good answer. I would make one suggestion, which is that I would not call what these packages distribute "pydoc documentation." Rather, the packages contain docstrings. These docstrings are used by pydoc, Sphinx, etc, to generate documentation.
I have used a package manager to install these packages. Now how do I run pydoc on these packages and use it to index the documentation?
This is done in the same way that using pydoc on modules in the standard library works. e.g. python -m pydoc numpy.linalg.solve will show you documentation for that function. I would look this page to get a full list of ways to use pydoc: docs.python.org/3/library/pydoc.html
1

If you can't get pydoc working, one alternative would be to download the documentation for offline use. You can usually find downloads of the documentation in HTML zip format for popular packages.

Examples:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.