8

Using Windows XP and Python 2.7 I tried to run "pydoc" through the terminal. unfortunately it doesn't work.

Since I'm not allowed to post a screenshot (Newbie). Here is what it says (white on black)

What I type:

"C:\Python27>pydoc raw_input  /"pydoc raw_input"

My result (It's German an it roughly translates to"The command "pydoc" is either spelled wrong or couldn't be found.):

Der Befehl "pydoc" ist entweder falsch geschrieben oder konnte nicht gefunden werden. 

What am I doing wrong?

By the way, I just started to teach myself programming using Zed Shaws "Learn Python the Hard Way" and this is the first issue I really can't figure out using Google. I start to believe that it is Windows an not me... (being too broke to afford a Mac and to scared to learn Linux).

idbrii
  • 10,975
  • 5
  • 66
  • 107
Twiek
  • 2,013
  • 2
  • 14
  • 14
  • 2
    You need to learn how to run scripts on Windows anyway (and you've got some good answers), but are you aware of the GUI documentation gadget found by clicking on Start > All Programs > Python 2.7 > Python manuals ? – John Machin Aug 02 '10 at 23:41
  • Screenshot: A bitmap screenshot is rarely necessary to display text. Just select the text in the command prompt window and paste it into your SO question. Then select it in your browser and click on the 010101 etc editing icon to format it as "code". – John Machin Aug 02 '10 at 23:46
  • I was aware of the Python manual but wanted to know how to start it through the command prompt window (hope I don'tmix up the words/terms). Regarding compying text from the command prompt window: I didn't know that this was possible, so thanks (Google told me how to... ). – Twiek Aug 03 '10 at 11:31

8 Answers8

8

for me

% python -m pydoc <params here>

worked. python will look for pydoc.py in the right directories without further ado.

akira
  • 6,050
  • 29
  • 37
5

pydoc is actually a Python script (so, on Windows, you need to look for pydoc.py), and it's not added to the Windows %PATH% by default (so you need to give a full pathname).

Try running c:\Python27\Lib\pydoc.py from your command line.

Edit: For a graphical interface to Python's documentation, you might want to instead run c:\Python27\Tools\Scripts\pydocgui.pyw (from the command line or from Windows Explorer). This starts pydoc's web server on your local PC so you can access the documentation through your web browser.

Josh Kelley
  • 56,064
  • 19
  • 146
  • 246
  • Thanks so much! Now I'm really glad that this problem made me try out Stack Overflow. – Twiek Aug 02 '10 at 22:23
  • 2
    If you don't know the installation path, you can run pydoc using the command `python -m pydoc ...`. – Cristian Ciupitu Sep 11 '10 at 01:32
  • This did not really answer Twiek's question. He wanted to know how to run 'pydoc' command from the command line. all the answers above are work arounds. The answer can be found at Dave Webb's answer below but he did not say where to place the pydoc.bat file he spoke of. My comments help clear that up. Happy to say pydoc now works for me on windows. –  Sep 12 '10 at 00:45
  • Dave Webb's answer is great, but I like Cristian's workaround in the commend above. – Ben McCormack Jun 26 '11 at 12:46
2

In Windows,you should type python pydoc.py in this directory(c:\Python27\lib) in the powershell,then you will see what you want.

PS: pay attention to the full path to pydoc.py

akjoshi
  • 15,374
  • 13
  • 103
  • 121
Pandar_H
  • 21
  • 3
2

There's no pydoc command in Windows. You'll need to specify the full path to pydoc.py. For example to start the pydoc GUI use:

python c:\Python26\lib\pydoc.py -g

If you want to add the pydoc command, create a pydoc.bat file with the following line in it:

@python c:\Python26\lib\pydoc.py %*
David Webb
  • 190,537
  • 57
  • 313
  • 299
  • where should one place the pydoc.bat file? –  Sep 12 '10 at 00:16
  • oh never mind. I figured out that it had to be placed in the Scripts folder which for me is C:\python27\Tools\Scripts. Thanks :) –  Sep 12 '10 at 00:38
2

you can also type help() when you are in the Python terminal which gets you to the same page...

http://docs.python.org/library/pydoc.html

chown
  • 51,908
  • 16
  • 134
  • 170
indre
  • 21
  • 1
1
  1. Check if path you've added to PATH is in there. Type in command line PATH. If path you've added isn't there then Restart Windows. If it is go next line.

  2. Type pydoc.py instead of pydoc

  3. If you don't want type pydoc module extension every time, just add .PY extension to PATHEXT variable located at the same place as PATH variable does (Computer → Properties → Advanced system settings → Advanced → Environment Variables... → System Variables → PATHEXT). Restart your Windows after adding of extension.

Paul
  • 78
  • 1
  • 3
  • 12
0

Just put C:\Python27\Lib in your PATH environment variable and be done with it once and for all. Works for me.

SkipKent
  • 457
  • 1
  • 6
  • 13
0

The simplest way to do this would be to change to the Python27/Lib directory and run the command from there, like so:

C:\Documents and Settings\username>cd C:\Python27\Lib

C:\Python27\Lib>python pydoc.py raw_input
Help on built-in function raw_input in module __builtin__:
Ryan M
  • 18,333
  • 31
  • 67
  • 74