19

pydoc does not work in Windows. at this post Pydoc is not working (Windows XP) the last answer by dave webb says to create a pydoc.bat file with this code in it:

@python c:\Python27\Lib\pydoc.py %*

After I create pydoc.bat where should it be placed so the pydoc command works in the command prompt?

PS adding C:\python27\Lib\pydoc.py to the Windows path in the system environment variables does not work. Even after logging out and back in it does not work.

Community
  • 1
  • 1
  • If you double click on a `*.py` file in Windows Explorer does it start running or is something else happening, e.g. the file is opened in an editor? Also as far as I can see, this question has been already answered. Maybe you should comment over there if you're not happy with those answers. – Cristian Ciupitu Sep 11 '10 at 01:30
  • a command prompt style window pops up for a fraction of a second and disappears when i double click a *.py file. i have not seen this question answered over here http://stackoverflow.com/questions/3391998/pydoc-is-not-working-windows-xp but I will comment there. –  Sep 12 '10 at 00:15

7 Answers7

29

Use python -m pydoc os instead of pydoc directly, no need to add to path variable.

the -m tells python that pydoc is a pre-built module in python and NOT a script (.py file) sitting in the current working folder.

See https://docs.python.org/3/using/cmdline.html for details

Spcogg
  • 173
  • 1
  • 5
invincible
  • 291
  • 3
  • 2
  • 3
    You can also start pydoc server with this command `python -m pydoc -p 8080`. Then go to http://localhost:8080 – Dmitry Jun 02 '16 at 11:30
9

PS adding C:\python27\Lib\pydoc.py to the Windows path in the system environment variables does not work. Even after logging out and back in it does not work.

The PATH environment variable is a list of directories to search for a given executable. So you should be adding C:\python27\Lib to your PATH (not including the filename).

As for the pydoc.bat file you've created, one place to put it would be the C:\python27\Scripts directory which is usually added to your PATH by the python installation (since that folder contains miscellaneous scripts that you might like available at the command line).

ars
  • 120,335
  • 23
  • 147
  • 134
  • the only Scripts folder I found is in C:\python27\Tools\Scripts. is this the same one you are referring to? –  Sep 12 '10 at 00:13
  • That sounds right -- I have python 2.5, so it may have changed. That should probably be in your path already, or you can put it there if it isn't. – ars Sep 12 '10 at 00:28
  • it worked but to get it to work I had to place pydoc.bat in C:\python27\Tools\Scripts not C:\python27\Scripts cause that DIR doesn't exist for me. thanks :) –  Sep 12 '10 at 00:36
4

I have found in windows 10 powershell...

Remember to access pydoc in windows, it's python -m pydoc. If you want to access info on "file", add the word "file" after. Like this "python -m pydoc file" (*w/o the quotes).

What you type after python -m pydoc, will tell it what info you want brought up and/or looking for. i.e. python -m pydoc raw_input, python -m pydoc string, python -m pydoc file.

Remmeber python -m pydoc must be in front of what you are looking for.

Adam
  • 41
  • 1
2

put it in any folder that is in your PATH. Example: C:\Windows\System32

Alternatively, you can put it anywhere, and then add the folder it is in to windows PATH

nosklo
  • 217,122
  • 57
  • 293
  • 297
1

I have a simple PowerShell script sitting in my "\python27\" directory called 'pydoc.ps1'. I can then call pydoc as intended...

ie.
c:> pydoc raw_input

code for 'pydoc.psi':

foreach ($i in $args)
    {python \python27\lib\pydoc.py $i}
mike
  • 11
  • 3
1

If you add .PY to your PATHEXT environment variable, you don't need the batch script. Just add C:\Python27\Lib to PATH, and you're all set.

Lstor
  • 2,265
  • 17
  • 25
0

As an example for Raw_input, try: python -m pydoc raw_input

Hussam
  • 9
  • 1
  • The problem going by the accepted answer seems to be that the path environment variable needed to be updated. – Ren Mar 27 '13 at 10:24