好的,这真的很奇怪……我在 Windows XP 上运行 Python 2.5,并使用 easy_install 来获取库 java2python。我试图运行 j2py.py,但每当我这样做时,它都会给我这个错误:
C:\Python25\Lib\site-packages>j2py.py
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\j2py.py", line 16, in
from java2python.compiler import Module, buildAST, transformAST
File "C:\Python25\Lib\site-packages\__init__.py", line 9, in
File "c:\python25\lib\site-packages\java2python-0.5.1-py2.5.egg\java2python\co
mpiler\block.py", line 16, in
File "c:\python25\lib\site-packages\java2python-0.5.1-py2.5.egg\java2python\co
mpiler\visitor.py", line 15, in
ImportError: cannot import name reduce
于是我进入了java2python-0.5.1-py2.5.egg文件夹,删除了reduce的导入。这仍然会导致错误,但我当时并不知道。我再次运行它,即使该行已被删除,它也有完全相同的错误。我将 java2python-0.5.1-py2.5.egg 目录的 java2python 文件夹移出到 site-packages 目录中,它给了我同样的错误。我从easy_install.pth中删除了java2python-0.5.1-py2.5.egg,同样的错误。我什至在同一个命令提示符下执行了这个命令:
C:\Python25\Lib\site-packages>cd c:\python25\lib\site-packages\java2python-0.5.1
-py2.5.egg\java2python\compiler
The system cannot find the path specified.
我只是不明白。为什么会这样?