4
我在我的jRuby/Rails項目中命令「import nltk」存在問題。有趣的是,如果我在重新啓動webrick之後第一次在webrick服務器上運行帶有「import nltk」的代碼,那麼一切正常。任何其他嘗試運行代碼的錯誤如下所示。任何想法爲什麼發生這種情況?我的Python是2.7,jRuby 1.6.7。導入NLTK期間Rubypython錯誤
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
.......
感謝您的建議,我的問題只與nltk庫(cPickle = RubyPython.import(「cPickle」))也適用於我)。所以也許這是與nltk和java相關的問題?另外有趣的是,首次調用'import nltk'的方式運行良好,並且nltk函數本身也能按預期工作。但是,任何嘗試運行代碼的錯誤都會結束。好吧,我打算玩一些版本。 – mantonn
我對Python生態系統根本不熟悉,但是如果NTLK是本機擴展,那麼我可以想象,圖片會變得比現在更加混亂。 rubypython + NTLK在MRI + FFI上工作嗎?畢竟,最好學習Python來使用NTLK。 – banzaiman