rodneyc8063
rodneyc8063

Reputation: 123

Python - Error when running the 'help()' command outside of the interpreter?

I am starting out playing around with Python and trying to understand how to navigate it.

I noticed that in the regular command line (Power shell) I can at times run a python command like 'python -m ABC' and it executes just fine.

I recently learned about the "help()" function within the Python interpreter so for example I would type help('modules') to display all the installed modules.

When I try to execute in the command line 'python -m help('modules')' I get an error saying "No module named help" but I literally can run it in the interpreter.

This is a totally low level question but just curious why do I get this error?

Upvotes: 0

Views: 142

Answers (1)

Carcigenicate
Carcigenicate

Reputation: 45750

help isn't a module; it's a callable class. To execute code, (which can include a call to a function/callable), you want -c:

python -c 'help(print)'

Upvotes: 1

Related Questions