How to get pydoc command working in Windows?

China☆狼群 提交于 2019-12-03 06:03:41

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).

invincible

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

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.

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

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.

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

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}

If you do some of your work on IDLE (Python GUI) on Windows, you can use help() inside IDLE and it will produce the same message.

example:

>>> help(time)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!