Skip to content Skip to sidebar Skip to footer

Windows 7 - Pydoc From Cmd

Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. S

Solution 1:

In Windows Powershell use: python -m pydoc

Examples:

python -m pydoc open

python -m pydoc raw_input

python -m pydoc argv

Solution 2:

When you type the name of a file at the windows command prompt, cmd can check the windows registry for the default file association, and use that program to open it. So if the Inkscape installer associated .py files with its own version of python, cmd might preferentially run that and ignore the PATH entirely. See this question.

Solution 3:

Based on your second edit, you may have more than one copy of pydoc.py in your path, with the 'wrong' one first such that when it starts up it doesn't have the correct environment in which to execute.

Solution 4:

python -m pydoc -k/p/g/w <name>

Solution 5:

Syntax for pydoc on windows:

alt1:

C:\path\PythonXX\python.exe C:\path\PythonXX\Lib\pydoc.py -k/p/g/w X:\path\file_to_doc.py

alt2:

python -m pydoc -k/p/g/w X:\path\file_to_doc.py

Of which the latter is the one to prefer, duh. However it requires your windows installation to have registered python to the environment variable "Path".

Setup windows environment variables:

Look at this site for a guide on where to find them. The one you'll be looking for is "Path". If you select Path and click Edit you will see a long row of paths pointing to different folders. The Path's you see here is what allows you to basically reach a veriety of programs in the command line by just entering the name of the program, instead of the whole path to it. So what you want to do here is to locate your Python installation and copy its full path like this: X:\subfolders\PythonXX\ Then you add it to the very end of the long row of Path's like this:

X:\earlier\path\to\something;X:\subfolders\PythonXX\

Notice the ";" that seperates the different paths, make sure not to forget it. When done, click to confirm/Ok, then you would need to restart any cmd.exe that's already open.

The pydoc.py

The thing is that pydoc is a module of the standard python lib, and it's also powered by python. The windows environment, of what I understand, requires you to specify with which program you want to run a certain file with. So to run the pydoc.py-file we would use:

Open file in windows cmd.exe:

X:\subfolders\Python27\python.exe X:\subfolders\Python27\Lib\pydoc.py

pydoc.py's arguments:

pydoc.py comes with a veriety of command line-based features that allows you to enter certain arguments: -k/p/g/w of which will trigger different behaviours of the pydoc.py-program.

Send arguments to a program through command line:

The syntax to enter these arguments is of what I know always after the x:\pathtofile\filename.suffix, seperated by a simple space. Which gives us the final:

alt1:

X:\subfolders\Python27\python.exe X:\subfolders\Python27\Lib\pydoc.py -w X:\path\file_to_doc.py

alt2 (with python registered to path):

python -m pydoc -w X:\path\file_to_doc.py

The "w"-option will give you a HTML-documentation for the file you want to run documentation on. Notice that pydoc.py will (according to my tests) create the documentation-file in the current working directory. Meaning that you will need to place yourself in a folder of choice before you actually run the command.

The function of -m

Of what I can find, the -m seem to handle registry entries, atleast in the msiexec.exe. I guess it might be used for programs in general this way. So my speculative idea of it is that if "-m" is applied, the pursuing arguments paths will be rewritten so that the .exe-file will be used as a path-reference. But as said, rather speculative.

-m Rewrites all required computer-specific registry entries. (in msiexec.exe) According to Microsoft

Post a Comment for "Windows 7 - Pydoc From Cmd"