开发者

How to get pydoc command working in Windows 7 cmd?

开发者 https://www.devze.com 2023-02-28 00:46 出处:网络
I\'m learning to program Python from the \"Learning Python the Hard Way\". On one of the chapters it tells me to use pydoc command. The windows 7 cmd failed miserably with that command.

I'm learning to program Python from the "Learning Python the Hard Way". On one of the chapters it tells me to use pydoc command. The windows 7 cmd failed miserably with that command.

When I typed in pydoc raw_input() on cmd following error codes were generated:

'pydoc' is not recognized as internal or external command,
operable program or batch file.

I've looked back previous two questions on same issue:

  1. Pydoc is not working (Windows XP)
  2. How to get pydoc command working in Windows?

So far I have created a pydoc.bat with following line

@python c:\Python26\lib\pydoc.py %*

and saved it in C:\python27\Tools\Scripts.

I've also tried to change the PATH to C:\python27\Lib. I called the two variables python and pydoc because 开发者_运维知识库I'm not really sure I set the PATH correctly.

It's still not working.

What did I do wrong?


To get help on python when in the PowerShell window, type:

python -m pydoc raw_input

substituting your function name for raw_input.


Hey I know this post is a bit old, but I wanted to let you (and anyone else out there) know about this:

C:\Python27\Tools\scripts\pydocgui.py

It sets up a webserver on localhost:7464. Simply visit the address in your browser and you have access to pydoc :) Hope this helps someone


You added this to your script file:

@python c:\Python26\lib\pydoc.py %*

But it seems that you are using python 2.7


I run a Windows 7. I am using the command prompt, cmd. I am learning Python from Learning Python the Hard Way. I was having the same problem as you, and attempted to solve it on my own from what you gave me. Here is what I got:

On gedit, I typed

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

It is important to note two parts:

The C:\ is capitalized, the L in Lib is capitalized. Both of those were left under-cased, and that created a syntax error when I tried to run it.

I saved this as

pydoc.bat

from gedit in C:\Python27\Tools\Scripts.

From cmd, I cd'd into the above address. From C:\Python27\Tools\Scripts I typed pydoc.bat open and it worked. It showed me the information I needed.

The only difference between what you did and what I did seems to be the capitalization of certain letters. Check your typing and ensure it fits what the computer needs to see.


Copy paste the bat file in this path.

C:\python27 

and then run it as :

pydoc.bat raw_input

this should work. make sure that the PATH is set to:

C:\python27

This will help you to run the bat file from anywhere in the cmd line


set the path as

C:\Python27>python (or wherever you installed python)

Then write command -m pydoc raw_input which will look as

C:\Python27>python -m pydoc raw_input

Note: There's a space between python and -m


There are several ways to fix it:

  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.


Type Pydoc.py x replacing x with whatever document you want to read.

For example Pydoc.py raw_input (in cmd ofcourse)

Do not forget to change path to the lib directory. do it like this:

Right click on my computer>properties>Advanced tab>environment variables> search for the value PATH in system variables>edit> enter this -> ;C:/Python27/lib


Here's how you do it from zero/layman (my kind of) condition, learning python:

If you have a Win7 32bit system with no environment variable set manually after installing (basically nothing else done after just installing it) python 2.7 or any version lower than python 3 from website, then follow these steps:

1) Open Command Line, and type (in exact case):

cd\

until you come back to "C:\" directory (root/base directory where your python is installed).

2) Then type:

cd Python27

As my base dir or drive is C drive, my path is this, yours may be different hence you type the route of Python27 (or 26 or the name of your python folder) folder where you have installed Python2.7 (or whatever version).

3) Then type:

cd Lib

You just entered the Library folder where pydoc.py file is present as per default installation from internet (for me it was the case).

4) Then simply type:

pydoc.py

You will get the required pydoc output which seems to be of the kinds of "man" page of PERL/Linux or the "Help" of C/Windows.

5) Then simply type:

pydoc.py raw_input

Name of the required command for which you want to see documentation.

Now you know how to do it for all the rest of the commands.


you must not be in correct directory in your command prompt while typing "pydoc raw_input"

first type:

cd\python27\lib

then type:

pydoc raw_input


I have the answer: see the thing is we been running pydoc raw_input in the cmd, but what we where forgetting is that to run python files we have to type .py at the end of the file im using windows 7 NVidia, to run you got to be in it's Dir C:\Python27\Lib, then type pydoc.py and enter.

There you go hope this was helpful.

0

精彩评论

暂无评论...
验证码 换一张
取 消