Ubuntu – What applications are available for reading Python documentation offline

documentationpythonsoftware-recommendation

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.

Best Answer

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.