I'm interested in reading Python documentation when I'm traveling.

Right now, I'm doing that by entering the command:

$ pydoc2.7 PyQt4.QtGui.QPushButton
Help on class QPushButton in PyQt4.QtGui:

PyQt4.QtGui.QPushButton = class QPushButton(QAbstractButton)
 |  QPushButton(QWidget parent=None)
 |  QPushButton(QString, QWidget parent=None)
 |  QPushButton(QIcon, QString, QWidget parent=None)
 |  Method resolution order:
 |      QPushButton
 |      ...
 |      ...
 |      ...

I don't really like this way of reading the documentation. I'm interested if there are other applications which let me read Python documentation offline.

  • 1
    pydoc -p 1234 starts a web server (http://localhost:1234/) which lists all libraries on the system. This still only shows documentation from inside the .py files though - most libraries provide some other sort of documentation but there isn't a sufficiently consistent standard for how to access them. – chronitis Oct 7 '13 at 10:02
  • See stackoverflow.com/a/26333949/562769 – Martin Thoma Oct 13 '14 at 16:16

Ubuntu provides the documentation for Python and its major libraries as different packages. The documentation is in HTML format and can be viewed in your browser once installed.

These documents are installed as a sub-directory in /usr/share/doc/. After installing the packages, we may browse to this folder and open the index.html file contained therein with our Browser and bookmark its location for easy access.

It's good to search Ubuntu Software Center for the package of the documentation you want. Use the keywords as:

  • python-<library_name>-doc for documentation relating to Python 2 third-party library; and
  • python3-<library_name>-doc for documentation relating to Python 3 third-party library.

You should be able to find them with some trial and error, otherwise Google is your friend.

Example for installing Python documentation and PyQt4 Reference Guide

Following is an example relating to:

Install the documentation package

sudo apt-get update
sudo apt-get install python-doc python-qt4-doc

Add as Browser bookmark

Open your File Manager and browse to /usr/share/doc/python-doc and look for index.html file to open it with your browser. Then add it as a bookmark.

Similarly, browse to /usr/share/doc/python-qt4-doc/html and look for index.html and add that as a bookmark. I would also suggest to bookmark the location of /usr/share/doc/python-qt4-doc/examples for some good example code written in PyQt4.

You may follow similar approach for having access to offline documentation for other third-party Python libraries.

  • 1
    Very handy. I've seen *-doc before when using apt-get, but I never knew its use. Thank you! – Exeleration-G Oct 7 '13 at 13:56

you could always download the documentation from here. But you need to keep it up-to-date with the online version.

  • Does this also include library documentation? I'm asking because I need to look up a lot of PyQt stuff. – Exeleration-G Oct 7 '13 at 9:35
  • @Exeleration-G well it says here that it does, To download an archive containing all the documents for this version of Python in one of various formats. But download one and search for the topics that you need and you will know for sure. – Alvar Oct 7 '13 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.