问题
When trying to use pydoc under Windows and python.org 2.6.4 I get the following error:
C:\>pydoc sys
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "C:\programs\Python26\Lib\pydoc.py", line 55, in ?
import sys, imp, os, re, types, inspect, __builtin__, pkgutil
File "C:\programs\Python26\Lib\os.py", line 758
bs = b""
^
SyntaxError: invalid syntax
What could be wrong here?
回答1:
Typical windows problem: I had a program installed lately which brought its own Python 2.4. This installation overwrote the Windows file handlers for python scripts, but did not appear on the PATH. So scripts started from the console ran in the old-version python, but calling "python" ran the 2.6 version.
Thx to Nadia for the first hint.
回答2:
how about setting your PATH
c:\> set PATH=C:\Python26\Lib;%PATH%
c:\> pydoc.py sys
来源:https://stackoverflow.com/questions/2199739/pydoc-fails-under-windows-and-python-2-6-4