【问题标题】:Error while installing Jython for PyDev为 PyDev 安装 Jython 时出错
【发布时间】:2012-05-02 12:26:48
【问题描述】:

我之前在 Eclipse 中安装了 PyDev 和 Jython,我从来没有遇到过问题。但是这次我遇到了手动或自动安装的错误:

Unable to gather the needed info from the system.

This usually means that your interpreter is not in
the system PATH.
No output was in the standard output when trying to create the interpreter info.
The error output contains:>>Traceback (innermost last):
  File "/home/michaele/Downloads/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 89, in ?
  File "/home/michaele/Downloads/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 46, in nativePath
  File "/home/michaele/Downloads/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 51, in fullyNormalizePath
AttributeError: class 'org.python.modules.os' has no attribute 'path'
<<

在命令行上使用 Jython 或 Python 运行相同的脚本似乎没问题:

$ python /eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py
<xml>
<version>2.6</version>
<executable>/usr/bin/python</executable>
<lib path="out">/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc</lib>
<lib path="ins">/usr/lib/python2.6</lib>
<lib path="ins">/usr/lib/python2.6/plat-linux2</lib>
<lib path="ins">/usr/lib/python2.6/lib-tk</lib>
<lib path="ins">/usr/lib/python2.6/lib-old</lib>
<lib path="ins">/usr/lib/python2.6/lib-dynload</lib>
<lib path="ins">/usr/local/lib/python2.6/dist-packages</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages/PIL</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages/gst-0.10</lib>
<lib path="ins">/usr/lib/pymodules/python2.6</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages/gtk-2.0</lib>
<lib path="ins">/usr/lib/pymodules/python2.6/gtk-2.0</lib>
<forced_lib>__builtin__</forced_lib>
<forced_lib>__main__</forced_lib>
<forced_lib>_ast</forced_lib>
<forced_lib>_bisect</forced_lib>
<forced_lib>_codecs</forced_lib>
<forced_lib>_collections</forced_lib>
<forced_lib>_functools</forced_lib>
<forced_lib>_hashlib</forced_lib>
<forced_lib>_locale</forced_lib>
<forced_lib>_random</forced_lib>
<forced_lib>_socket</forced_lib>
<forced_lib>_sre</forced_lib>
<forced_lib>_ssl</forced_lib>
<forced_lib>_struct</forced_lib>
<forced_lib>_symtable</forced_lib>
<forced_lib>_warnings</forced_lib>
<forced_lib>_weakref</forced_lib>
<forced_lib>array</forced_lib>
<forced_lib>binascii</forced_lib>
<forced_lib>cPickle</forced_lib>
<forced_lib>cStringIO</forced_lib>
<forced_lib>errno</forced_lib>
<forced_lib>exceptions</forced_lib>
<forced_lib>fcntl</forced_lib>
<forced_lib>gc</forced_lib>
<forced_lib>grp</forced_lib>
<forced_lib>imp</forced_lib>
<forced_lib>itertools</forced_lib>
<forced_lib>marshal</forced_lib>
<forced_lib>math</forced_lib>
<forced_lib>operator</forced_lib>
<forced_lib>posix</forced_lib>
<forced_lib>pwd</forced_lib>
<forced_lib>select</forced_lib>
<forced_lib>signal</forced_lib>
<forced_lib>spwd</forced_lib>
<forced_lib>strop</forced_lib>
<forced_lib>sys</forced_lib>
<forced_lib>syslog</forced_lib>
<forced_lib>thread</forced_lib>
<forced_lib>time</forced_lib>
<forced_lib>unicodedata</forced_lib>
<forced_lib>xxsubtype</forced_lib>
<forced_lib>zipimport</forced_lib>
<forced_lib>zlib</forced_lib>
</xml>Traceback (most recent call last):
  File "/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 142, in <module>
    raise RuntimeError('Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).')
RuntimeError: Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).
$ jython /eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py
<xml>
<version>2.2</version>
<executable>None</executable>
<lib path="out">/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc</lib>
<lib path="ins">/usr/share/jython/Lib</lib>
<lib path="out">/usr/lib/site-python</lib>
<lib path="out">__classpath__</lib>
<forced_lib>sets</forced_lib>
<forced_lib>cPickle</forced_lib>
<forced_lib>math</forced_lib>
<forced_lib>thread</forced_lib>
<forced_lib>md5</forced_lib>
<forced_lib>_jython</forced_lib>
<forced_lib>py_compile</forced_lib>
<forced_lib>time</forced_lib>
<forced_lib>jarray</forced_lib>
<forced_lib>array</forced_lib>
<forced_lib>os</forced_lib>
<forced_lib>xreadlines</forced_lib>
<forced_lib>operator</forced_lib>
<forced_lib>binascii</forced_lib>
<forced_lib>_sre</forced_lib>
<forced_lib>errno</forced_lib>
<forced_lib>synchronize</forced_lib>
<forced_lib>types</forced_lib>
<forced_lib>ucnhash</forced_lib>
<forced_lib>pre</forced_lib>
<forced_lib>struct</forced_lib>
<forced_lib>_weakref</forced_lib>
<forced_lib>new</forced_lib>
<forced_lib>imp</forced_lib>
<forced_lib>exceptions</forced_lib>
<forced_lib>cStringIO</forced_lib>
<forced_lib>sha</forced_lib>
<forced_lib>_codecs</forced_lib>
</xml>Traceback (innermost last):
  File "/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 142, in ?
RuntimeError: Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).

也可以使用 Python 或 Jython 从 Eclipse 中的交互式控制台运行,即:

Python:

import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
/usr/bin/python2.6 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) 
[GCC 4.4.5]
PyDev console: using default backend (IPython not available).
import os
os.path.normpath('/')
'/'

Jython:

import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
--->  reloading /eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/pydevconsole.py
PyDev console: using default backend (IPython not available).

You are now in a console within Eclipse.
Use it with care as it can halt the VM.
Typing a line with "PYDEV_CONSOLE_TOGGLE_RUN_IN_UI"
will start executing all the commands in the UI thread.

java1.6.0_21 2.2.1
import os
os.path.normpath('/')
'/'

环境信息:

OS- Ubuntu 10.10 Maverick

Eclipse- Version: Indigo Service Release 2
         Build id: 20120216-1857

Python- 2.6.6

Jython- 2.2.1 on java1.6.0_21

Java- java version "1.6.0_21"
      Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
      Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)

抱歉,这篇文章很长,但我不知道什么是相关的。我已经尝试了所有我能想到的让 Jython 在 PyDev 中工作的方法都无济于事。任何帮助将不胜感激。

谢谢,

迈克

EDIT1:添加对 Fabio 的响应

感谢您提供的所有建议,我感谢您的帮助。但还是不行。

  1. 导致此错误:

无法从系统收集所需的信息。

This usually means that your interpreter is not in
the system PATH.
No output was in the standard output when trying to create the interpreter info.
The error output contains:>>Traceback (innermost last):
  File "/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 15, in ?
ImportError: no module named javaos
<<

这对我来说毫无意义。

  1. 给出了同样的错误:

无法从系统收集所需的信息。

This usually means that your interpreter is not in
the system PATH.
No output was in the standard output when trying to create the interpreter info.
The error output contains:>>Traceback (innermost last):
  File "/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 89, in ?
  File "/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 46, in nativePath
  File "/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 51, in fullyNormalizePath
AttributeError: class 'org.python.modules.os' has no attribute 'path'
<<
  1. 来自日食:

    无法从系统收集所需的信息。

    这通常意味着您的口译员不在 系统路径。 尝试创建解释器信息时,标准输出中没有输出。 错误输出包含:>> Traceback (innermost last): (无代码对象)在第 0 行 文件“/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py”,第 17 行 print('\n'.join(sorted(str(x) for x in os.environ.items()))) ^ SyntaxError:无效的语法

从控制台:

python /eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py
('COLORTERM', 'gnome-terminal')
('DBUS_SESSION_BUS_ADDRESS', 'unix:abstract=/tmp/dbus-sgAQf9jF15,guid=95ee83c3b3510c530cb4ea8500000066')
('DEFAULTS_PATH', '/usr/share/gconf/gnome.default.path')
('DESKTOP_SESSION', 'gnome')
('DISPLAY', ':0.0')
('GDMSESSION', 'gnome')
('GDM_KEYBOARD_LAYOUT', 'us')
('GDM_LANG', 'en_US.utf8')
('GNOME_DESKTOP_SESSION_ID', 'this-is-deprecated')
('GNOME_KEYRING_CONTROL', '/tmp/keyring-JsqHSQ')
('GNOME_KEYRING_PID', '1799')
('GTK_MODULES', 'canberra-gtk-module')
('HOME', '/home/michaele')
('LANG', 'en_US.utf8')
('LOGNAME', 'michaele')
('MANDATORY_PATH', '/usr/share/gconf/gnome.mandatory.path')
('ORBIT_SOCKETDIR', '/tmp/orbit-michaele')
('PATH', '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games')
('PWD', '/home/michaele')
('SESSION_MANAGER', 'local/michaele-Dell-System-XPS-L702X:@/tmp/.ICE-unix/1818,unix/michaele-Dell-System-XPS-L702X:/tmp/.ICE-unix/1818')
('SHELL', '/bin/bash')
('SHLVL', '1')
('SSH_AGENT_PID', '1848')
('SSH_AUTH_SOCK', '/tmp/keyring-JsqHSQ/ssh')
('TERM', 'xterm')
('USER', 'michaele')
('USERNAME', 'michaele')
('WINDOWID', '67108892')
('WINDOWPATH', '7')
('XAUTHORITY', '/var/run/gdm/auth-for-michaele-cd81Hc/database')
('XDG_CONFIG_DIRS', '/etc/xdg/xdg-gnome:/etc/xdg')
('XDG_DATA_DIRS', '/usr/share/gnome:/usr/local/share/:/usr/share/')
('XDG_SESSION_COOKIE', '6b516b0ac1421896dc0de6dc00000009-1335548722.708677-1288196033')
('_', '/usr/bin/python')
<xml>
<version>2.6</version>
<executable>/usr/bin/python</executable>
<lib path="out">/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc</lib>
<lib path="ins">/usr/lib/python2.6</lib>
<lib path="ins">/usr/lib/python2.6/plat-linux2</lib>
<lib path="ins">/usr/lib/python2.6/lib-tk</lib>
<lib path="ins">/usr/lib/python2.6/lib-old</lib>
<lib path="ins">/usr/lib/python2.6/lib-dynload</lib>
<lib path="ins">/usr/local/lib/python2.6/dist-packages</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages/PIL</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages/gst-0.10</lib>
<lib path="ins">/usr/lib/pymodules/python2.6</lib>
<lib path="ins">/usr/lib/python2.6/dist-packages/gtk-2.0</lib>
<lib path="ins">/usr/lib/pymodules/python2.6/gtk-2.0</lib>
<forced_lib>__builtin__</forced_lib>
<forced_lib>__main__</forced_lib>
<forced_lib>_ast</forced_lib>
<forced_lib>_bisect</forced_lib>
<forced_lib>_codecs</forced_lib>
<forced_lib>_collections</forced_lib>
<forced_lib>_functools</forced_lib>
<forced_lib>_hashlib</forced_lib>
<forced_lib>_locale</forced_lib>
<forced_lib>_random</forced_lib>
<forced_lib>_socket</forced_lib>
<forced_lib>_sre</forced_lib>
<forced_lib>_ssl</forced_lib>
<forced_lib>_struct</forced_lib>
<forced_lib>_symtable</forced_lib>
<forced_lib>_warnings</forced_lib>
<forced_lib>_weakref</forced_lib>
<forced_lib>array</forced_lib>
<forced_lib>binascii</forced_lib>
<forced_lib>cPickle</forced_lib>
<forced_lib>cStringIO</forced_lib>
<forced_lib>errno</forced_lib>
<forced_lib>exceptions</forced_lib>
<forced_lib>fcntl</forced_lib>
<forced_lib>gc</forced_lib>
<forced_lib>grp</forced_lib>
<forced_lib>imp</forced_lib>
<forced_lib>itertools</forced_lib>
<forced_lib>marshal</forced_lib>
<forced_lib>math</forced_lib>
<forced_lib>operator</forced_lib>
<forced_lib>posix</forced_lib>
<forced_lib>pwd</forced_lib>
<forced_lib>select</forced_lib>
<forced_lib>signal</forced_lib>
<forced_lib>spwd</forced_lib>
<forced_lib>strop</forced_lib>
<forced_lib>sys</forced_lib>
<forced_lib>syslog</forced_lib>
<forced_lib>thread</forced_lib>
<forced_lib>time</forced_lib>
<forced_lib>unicodedata</forced_lib>
<forced_lib>xxsubtype</forced_lib>
<forced_lib>zipimport</forced_lib>
<forced_lib>zlib</forced_lib>
</xml>Traceback (most recent call last):
  File "/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 143, in <module>
    raise RuntimeError('Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).')
RuntimeError: Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).

【问题讨论】:

    标签: python eclipse jython pydev


    【解决方案1】:

    在尝试将 Jython 解释器添加到 Eclipse 时,我遇到了类似的问题,收到“从解释器获取信息时出错”消息。就我而言,我使用的是我自己构建的 Jython 版本。

    当您在根 jython 目录中运行 ant 构建(不带选项)时,它将生成 dist/jython-dev.jar。此 jar 文件与您从 jython 网站下载的 jar 文件不同,因为它没有捆绑 jython 需要的所有第三方 jar。不过,ant 生成的 dist/bin/jython 脚本会将这些添加到类路径中。

    Pydev 不使用该脚本来运行 Jython,它只是使用 jar 文件并假定它包含所需的一切。要获取解释器信息,Pydev 运行如下命令:

    /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java -Dpython.home=/Users/me/dev/projects/jython/dist -classpath /Users/me/dev/projects/jython/dist/jython-dev.jar org.python.util.jython /Users/me/dev/projects/Pydev/plugins/org.python.pydev/pysrc/interpreterInfo.py
    

    您可以通过在 jython 根文件夹中运行以下命令来编译捆绑所有需求的 jython.jar 文件:

    ant jar-complete
    

    这会将 jython.jar 放入 dist 文件夹中,该文件夹应该可以与 Pydev 一起正常工作。

    【讨论】:

      【解决方案2】:

      必须说我以前从未见过那个:)

      我可以想象的一些事情可能会解决它:

      1. 尝试改变:

        \plugins\org.python.pydev_2.5.0.2012040618\PySrc\interpreterInfo.py

        变化:

        导入操作系统

        到:

        导入 os.path

      2. 1234563就是这样)。
      3. 如果还是不行,请执行以下操作:

        在interpreterInfo.py 脚本的开头(在“import os”之后)

        做:

        print('\n'.join(sorted(str(x) for x in os.environ.items())))

        然后尝试配置解释器并将该日志发布到帖子中。然后,还要从控制台运行interpreterInfo.py 并将其也添加到帖子中(以查看环境是否有任何差异)。

      【讨论】:

      • 感谢您的建议,我已经用您要求的信息更新了帖子,但仍然没有成功。
      • 好吧,真正的问题似乎是,当从 Eclipse 内部运行时,jython 无法找到 javaos.py 文件(实际上映射到 os.path),该文件应该在Jython 库...现在一个简单的解决方法是编辑interpreterInfo.py,以便完全正常化路径(路径)只是“返回路径”(而不是使用 os.path.normpath)。
      • 感谢这似乎让我通过了安装。现在开始新的更令人兴奋的错误!
      猜你喜欢
      • 2012-08-25
      • 1970-01-01
      • 2017-08-14
      • 2012-08-04
      • 2012-09-14
      • 2012-05-26
      • 1970-01-01
      • 2011-01-17
      • 2014-02-07
      相关资源
      最近更新 更多