12

我正在从“Learning Python the Hard Way”中学习 Python 编程。在其中一章中,它告诉我使用 pydoc 命令。Windows 7 cmd 使用该命令惨遭失败。

当我在pydoc raw_input()cmd 上输入时,生成了以下错误代码:

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

我回顾了前两个关于同一问题的问题:

  1. Pydoc 不工作 (Windows XP)
  2. 如何让 pydoc 命令在 Windows 中工作?

到目前为止,我已经创建了一个带有以下行的 pydoc.bat

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

并将其保存在C:\python27\Tools\Scripts.

我也尝试将 PATH 更改为C:\python27\Lib. 我将这两个变量称为 python 和 pydoc,因为我不确定我是否正确设置了 PATH。

它仍然无法正常工作。

我做错了什么?

4

11 回答 11

19

要在 PowerShell 窗口中获取有关 python 的帮助,请键入:

python -m pydoc raw_input

用你的函数名代替 raw_input。

于 2013-04-05T15:32:07.687 回答
4

嘿,我知道这篇文章有点老了,但我想让你(和其他任何人)知道这一点:

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

它在localhost:7464. 只需访问浏览器中的地址,您就可以访问pydoc:) 希望这对某人有所帮助

于 2012-02-14T20:53:07.550 回答
3

您将此添加到脚本文件中:

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

但似乎您使用的是 python 2.7

于 2011-04-23T07:08:58.313 回答
2

我运行的是 Windows 7。我正在使用命令提示符 cmd。我正在从艰难地学习 Python 中学习 Python。我和你有同样的问题,并试图根据你给我的东西自己解决。这是我得到的:

gedit,我输入

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

重要的是要注意两个部分:

C:\ 大写,Lib 中的 L 大写。这两个都没有大写,当我尝试运行它时会产生语法错误。

我把它保存为

pydoc.bat

来自C:\Python27\Tools\Scripts中的 gedit 。

从 cmd,我 cd'd 进入上述地址。从C:\Python27\Tools\Scripts我输入pydoc.bat open 并且它工作。它向我展示了我需要的信息。

你所做的和我所做的唯一区别似乎是某些字母的大写。检查您的打字并确保它符合计算机需要查看的内容。

于 2011-07-24T18:36:54.857 回答
0

将bat文件复制粘贴到此路径中。

C:\python27 

然后运行它:

pydoc.bat raw_input

这应该有效。确保 PATH 设置为:

C:\python27

这将帮助您从 cmd 行中的任何位置运行 bat 文件

于 2011-04-23T07:54:48.383 回答
0

将路径设置为

C:\Python27>python (或安装 python 的任何位置)

然后编写命令-m pydoc raw_input ,它看起来像

C:\Python27>python -m pydoc raw_input

注意:python 和 -m 之间有一个空格

于 2016-08-28T08:11:45.700 回答
-1

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.

于 2011-06-23T20:06:16.633 回答
-1

这是从零/外行(我的那种)条件开始学习python的方法:

如果您的 Win7 32 位系统在安装后没有手动设置环境变量(安装后基本上没有其他操作)python 2.7 或网站上的任何低于 python 3 的版本,请按照以下步骤操作:

1)打开命令行,然后输入(在确切的情况下):

cd\

直到您回到“C:\”目录(安装了 python 的根/基本目录)。

2)然后输入:

cd Python27

由于我的基本目录或驱动器是 C 驱动器,因此我的路径是这样的,您的路径可能不同,因此您输入安装 Python2.7(或任何版本)的 Python27(或 26 或 python 文件夹的名称)文件夹的路径.

3)然后输入:

cd Lib

您刚刚进入了 pydoc.py 文件所在的 Library 文件夹,这是根据 Internet 的默认安装(对我来说就是这种情况)。

4)然后只需键入:

pydoc.py

您将获得所需的 pydoc 输出,这似乎是 PERL/Linux 的“手册”页或 C/Windows 的“帮助”。

5)然后只需键入:

pydoc.py raw_input

您要查看其文档的所需命令的名称。

现在您知道如何对所有其余命令执行此操作了。

于 2013-09-28T12:20:46.630 回答
-1

键入 Pydoc.py x 将 x 替换为您要阅读的任何文档。

例如 Pydoc.py raw_input(当然在 cmd 中)

不要忘记更改 lib 目录的路径。像这样做:

右键我的电脑>属性>高级选项卡>环境变量>在系统变量中搜索值PATH>编辑>输入这个->;C:/Python27/lib

于 2012-12-27T15:59:45.517 回答
-2

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.

于 2011-09-21T05:02:44.103 回答
-2

键入“pydoc raw_input”时,您不能在命令提示符下位于正确的目录中

第一种:

cd\python27\lib

然后输入:

pydoc raw_input
于 2012-08-10T16:03:01.660 回答