gpt4 book ai didi

python - 导入 NLTK 时出现 Rubypython 错误

转载 作者:太空宇宙 更新时间:2023-11-03 12:09:25 32 4
gpt4 key购买 nike

我的 jRuby/Rails 项目中的命令“import nltk”有问题。有趣的是,如果我在重新启动 webrick 后第一次在 webrick 服务器上使用“import nltk”运行代码,一切都会正常运行。任何其他运行代码的尝试都会以如下所示的错误结束。知道为什么会这样吗?我的 Python 是 2.7,jRuby 1.6.7。

在 jruby 代码中,我简单地调用:

RubyPython.start # start the Python interpreter

nltk = RubyPython.import("nltk")

RubyPython.stop # stop the Python interpreter

第二次调用上述代码后出现错误:

#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x89c9cc7a, pid=9774, tid=2319420224
#
# JRE version: 7.0_06-b24
# Java VM: Java HotSpot(TM) Server VM (23.2-b09 mixed mode linux-x86 )
# Problematic frame:
# C [multiarray.so+0x78c7a] _strided_zero_pad_data_copy+0x3106a
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

--------------- T H R E A D ---------------

Current thread (0x0a646400): JavaThread "RubyThread-13: /usr/lib/jruby/lib/ruby/1.8/webrick/server.rb:162" daemon [_thread_in_native, id=9817, stack(0x8a1f8000,0x8a3f9000)]

siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x00000001

Registers:
EAX=0x00000001, EBX=0x89d28ff4, ECX=0x00000001, EDX=0x8b879ad8
ESP=0x8a3c7d94, EBP=0x00000000, ESI=0x89d2c860, EDI=0x89d2c860
EIP=0x89c9cc7a, EFLAGS=0x00210202, CR2=0x00000001

Top of Stack: (sp=0x8a3c7d94)
0x8a3c7d94: 8b28f16c 8b2c78b8 89c303bd 89d28ff4
0x8a3c7da4: 89ddd21b 89d28ff4 89fb2680 89c7fa64
0x8a3c7db4: 89fb2680 89d2ba80 8b72aacc 89e536a4
0x8a3c7dc4: 89d28ff4 8bb85d54 8b879ad0 89cb601c
0x8a3c7dd4: 00000011 89d2bb60 8b829780 89e97d99
0x8a3c7de4: 00000007 8bb42840 8c54d71c 89d28ff4
0x8a3c7df4: 8b4f8c88 89d2c860 00000000 89cb80dc
0x8a3c7e04: 8b879ad8 89d2c860 00000004 00000000

Instructions: (pc=0x89c9cc7a)
0x89c9cc5a: 89 04 24 e8 ae 25 f9 ff 85 c0 75 8a 83 c4 5c 5b
0x89c9cc6a: 5e 5f 5d c3 66 90 8b 54 24 70 8b 02 85 c0 74 ec
0x89c9cc7a: 83 00 01 83 c4 5c 5b 5e 5f 5d c3 8d 74 26 00 8d
0x89c9cc8a: bc 27 00 00 00 00 53 83 ec 18 8b 54 24 20 e8 fa

Register to memory mapping:

EAX=0x00000001 is an unknown value
EBX=0x89d28ff4: <offset 0x104ff4> in /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so at 0x89c24000
ECX=0x00000001 is an unknown value
EDX=0x8b879ad8 is an unknown value
ESP=0x8a3c7d94 is pointing into the stack for thread: 0x0a646400
EBP=0x00000000 is an unknown value
ESI=0x89d2c860: <offset 0x108860> in /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so at 0x89c24000
EDI=0x89d2c860: <offset 0x108860> in /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so at 0x89c24000


Stack: [0x8a1f8000,0x8a3f9000], sp=0x8a3c7d94, free space=1855k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [multiarray.so+0x78c7a] _strided_zero_pad_data_copy+0x3106a

[error occurred during error reporting (printing native stack), id 0xb]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.kenai.jffi.Foreign.invokeArrayO1Int32(J[BLjava/lang/Object;III)I+0
.......

最佳答案

看起来 ruby​​python 用 FFI 发挥了它的魔力。如果 FFI 二进制文件(JRuby 附带)和/或您使用的 JVM 有问题,当 JVM 出现段错误时您无能为力。

尝试更新的 JRuby 版本和/或 JVM,但除此之外,恐怕您不会在这里获得太多帮助。

也就是说,它适用于我的 Mac。

$ cat test.rb               
require "rubypython"

RubyPython.start # start the Python interpreter

cPickle = RubyPython.import("cPickle")
p cPickle.dumps("Testing RubyPython.").rubify

RubyPython.stop # stop the Python interpreter
$ jruby -v; jruby -rubygems test.rb
jruby 1.7.0.preview2 (1.9.3p203) 2012-08-22 ff42564 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_04-b21 [darwin-x86_64]
"S'Testing RubyPython.'\np1\n."

关于python - 导入 NLTK 时出现 Rubypython 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12122163/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com