I have just installed Python 2.7 and Python 3.2 on my Ubuntu 12.04 (32 bit).

sudo apt-get install python python-doc python3 python3-doc

I opened a Python 3 shell (is it called like that) typing python3 from a terminal. If I issue the command help('print') everything works fine and I can read the documentation.

However if I open a Python 2.7 shell (python from a terminal) when I type help('print') I get the following message:

no documentation found for 'print'

How can I get to use the documentation in Python 2.7 as well?


This looks like a bug of Python 2 as something like help("dir") works properly. It probably does not work because print is a special keyword, unlike Python 3. Stick to Python 3 or run the following command instead of help("print"):


That documentation is always installed , because it is embedded on the source files. The specified command does not work because in python2.7 print is both a statement and a function, so it may be confusing the help function.

If you use, for example help('os') or help("if") you should get the correct information:

$ python -c "help('if')"
The ``if`` statement

The ``if`` statement is used for conditional execution:

   if_stmt ::= "if" expression ":" suite
               ( "elif" expression ":" suite )*
               ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section *Boolean operations*
for the definition of true and false); then that suite is executed
(and no other part of the ``if`` statement is executed or evaluated).
If all expressions are false, the suite of the ``else`` clause, if
present, is executed.

So the documentation is installed and that behavior you see should be a bug.

  • help('if') works in a python shell too. It is just that help('print') works differently (read: does not show a help page): python2 -c "help('print')". – Lekensteyn Dec 20 '12 at 20:24

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.