为什么会出现分段错误!当我尝试运行/使用 Python 包 gensim 时?

发布于 2024-11-17 20:51:31 字数 7120 浏览 4 评论 0原文

我正在尝试在我的一些机器学习实验中使用[gensim][1],这是一个用于Python的向量空间建模包。我按照这里所述的安装说明进行操作,但安装了按照他们的建议使用 easy_install 时,我的 OpenSuse 11.3 上的 scipy 失败了,因此我求助于从官方软件包搜索门户上提供的软件包安装它 此处

scipy 的安装顺利,然后我按照他们的建议使用 easy_install 安装 gensim 。这也很顺利。

现在,安装后,我尝试运行他们给出的使用该包的第一个示例,该示例以一个简单的导入语句开头,如下所示:

from gensim import corpora, models, similarities

Lo!当我尝试在我的 python 解释器中运行它时,亲爱的东西因分段错误而崩溃了!发生的事情是这样的:

>>> from gensim import corpora, models, similarities
Segmentation fault

有人救救我,因为我不知道错误可能来自哪里。

我知道段错误通常是由于进程的非法内存访问造成的,那么这可能是由于导入而发生的吗?或者 gensim 中出现一些错误?

更多信息,据说安装包后可以测试,所以我这样做是为了测试我的gensim,Lo!同样的分段错误!这是输出:

python setup.py test
running test
running egg_info
writing requirements to gensim.egg-info/requires.txt
writing gensim.egg-info/PKG-INFO
writing top-level names to gensim.egg-info/top_level.txt
writing dependency_links to gensim.egg-info/dependency_links.txt
reading manifest file 'gensim.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.sh' under directory '.'
writing manifest file 'gensim.egg-info/SOURCES.txt'
running build_ext
Segmentation fault

对于依赖包,我有:

>>> numpy.version.version
'1.3.0'

>>> scipy.version.version
'0.8.0'

好的,按照注释中的要求,我确实将 gdb 挂钩到解释器,然后再次尝试 import 语句,然后这就是再次发生段错误时 gdb 给出的结果:

(gdb) continue
Continuing.
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/time.so
Try: zypper install -C "debuginfo(build-id)=da29868e88d517efc61eed319c4a87b41404f932"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/strop.so
Try: zypper install -C "debuginfo(build-id)=1a5723f070198420ae565b728f267f00ae7e9885"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/cStringIO.so
Try: zypper install -C "debuginfo(build-id)=d02dafc8dd403786b35ee44d946fc67461c7af34"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_functools.so
Try: zypper install -C "debuginfo(build-id)=4d3d7d73a2d7abe3d4ac45bdc07a070abde67a3b"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_collections.so
Try: zypper install -C "debuginfo(build-id)=86c7e2481ef3930f858927648d270a96ef65e0d9"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/operator.so
Try: zypper install -C "debuginfo(build-id)=ecdf6c9dfbb007d3698e4108e2412b575b14c3f0"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/unicodedata.so
Try: zypper install -C "debuginfo(build-id)=b84b2bd4061ce43b8fe6e7319d0e3fe90431f3f9"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/cPickle.so
Try: zypper install -C "debuginfo(build-id)=0cb3d3c8e51cd264b7fc0cfd6ad6cea7da6173f1"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/itertools.so
Try: zypper install -C "debuginfo(build-id)=88125d7ede2ef83a18e46901c9b7bd938d7554b9"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_bisect.so
Try: zypper install -C "debuginfo(build-id)=e872da9d2f7456947a21d6cf8ac05115da084ee0"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_heapq.so
Try: zypper install -C "debuginfo(build-id)=0c250b23be656b9984a8fbf67c232930141c6a79"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/math.so
Try: zypper install -C "debuginfo(build-id)=48f975758f43cffc37703cda98615cb2daaf8a08"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/multiarray.so
Try: zypper install -C "debuginfo(build-id)=adcbae28e6012eecb870c60af4805f25554c9148"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/umath.so
Try: zypper install -C "debuginfo(build-id)=1087f0837567a96e6db9fadb8258f21113173f01"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/_sort.so
Try: zypper install -C "debuginfo(build-id)=c70e9c08253546b727376f7643cc9b6cc796465e"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/scalarmath.so
Try: zypper install -C "debuginfo(build-id)=cbc4ec89676c6072f64ae92a2917548479141eee"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/lib/_compiled_base.so
Try: zypper install -C "debuginfo(build-id)=6f71bf761290527c07afe78736211d2393caa95e"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/linalg/lapack_lite.so
Try: zypper install -C "debuginfo(build-id)=ac2cb74a8a055e3d58e15f4ac0012159abbf7d1a"
Missing separate debuginfo for /usr/lib/liblapack.so.3
Try: zypper install -C "debuginfo(build-id)=5c9cf054c3e366ea04681d3c3b1e4d1fa8b46da5"
Missing separate debuginfo for /usr/lib/libblas.so.3
Try: zypper install -C "debuginfo(build-id)=c7ea0a3cdf0da62f1f07f81838207e6070e86449"
Missing separate debuginfo for /usr/lib/libgfortran.so.3
Try: zypper install -C "debuginfo(build-id)=6889f5fdc16cb8d7cb4d5e97c59080336c2e6e01"
Missing separate debuginfo for /lib/libgcc_s.so.1
Try: zypper install -C "debuginfo(build-id)=ea12a9f70518dd6b807755150f1d2c6ba8550fe1"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/fft/fftpack_lite.so
Try: zypper install -C "debuginfo(build-id)=32599ba87256834ebc65a962e4718aa1f9134b0e"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/random/mtrand.so
Try: zypper install -C "debuginfo(build-id)=e43ddcab2e8e2961f3ab58087ac55dffa4094993"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_ctypes.so
Try: zypper install -C "debuginfo(build-id)=40cde5dd7ee47a3caac1ce1f94b6ef7fa28792ff"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_struct.so
Try: zypper install -C "debuginfo(build-id)=a5c456fe75e29e3424d7881fc05be8321fa65707"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/binascii.so
Try: zypper install -C "debuginfo(build-id)=d3a2d6b38432a2b5076e238aef398cd3776bed20"
Missing separate debuginfo for /lib/libz.so.1
Try: zypper install -C "debuginfo(build-id)=afddd839a6c18dd308b04b5289c56cc3abd1384f"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_random.so
Try: zypper install -C "debuginfo(build-id)=683d2819c1613d54dcd68c9169fc043ecb1b5444"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/fcntl.so
Try: zypper install -C "debuginfo(build-id)=aaabeb0dbb01b7a14698fd221d09fedc6de19521"
Missing separate debuginfo for /usr/lib/libjpeg.so.8
Try: zypper install -C "debuginfo(build-id)=5656b9563c388beee6e716dbe832ecb4480895ba"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/array.so
Try: zypper install -C "debuginfo(build-id)=4e4aea1f2106d4a7a7b4dbd51199e337549b83e2"
Missing separate debuginfo for /usr/lib/libstdc++.so.6
Try: zypper install -C "debuginfo(build-id)=181385b3f6f58b2e13543468f07e08c5edd2cd86"

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()

Am attempting to use [gensim][1], a Vector Space Modelling package for python in some Machine Learning experiments of mine. I followed their installation instructions as said here, though installation of scipy on my OpenSuse 11.3 failed when using easy_install as they recommend, so I resorted to installing it from a package available on the Official package search portal here.

Installation of scipy went ok, and then I used easy_install to install gensim as they recommend. Which also went ok.

Now, after installation, I attempted to run the very first example they give of using the package, which starts with a humble import statement as follows:

from gensim import corpora, models, similarities

Lo! When I attempted to run that in my python interpreter, the dear thing crashed with Segmentation Fault! This is what happened:

>>> from gensim import corpora, models, similarities
Segmentation fault

Someone save me, because I don't know where the error could possibly be coming from.

I understand the segfault usually is due to illegal memory access by a process, so could this be happening due to the import? or some error within gensim?

For more info, it is said that after installing the package it can be tested, so I did this to test my gensim, Lo! the same Segmentation Fault! Here is the ouput:

python setup.py test
running test
running egg_info
writing requirements to gensim.egg-info/requires.txt
writing gensim.egg-info/PKG-INFO
writing top-level names to gensim.egg-info/top_level.txt
writing dependency_links to gensim.egg-info/dependency_links.txt
reading manifest file 'gensim.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.sh' under directory '.'
writing manifest file 'gensim.egg-info/SOURCES.txt'
running build_ext
Segmentation fault

For the dependent packages, I have:

>>> numpy.version.version
'1.3.0'

>>> scipy.version.version
'0.8.0'

Ok, as requested in the comments, I did hook gdb to the interpreter, and then tried the import statement again, then this is what gdb gave when the segfault occurred again:

(gdb) continue
Continuing.
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/time.so
Try: zypper install -C "debuginfo(build-id)=da29868e88d517efc61eed319c4a87b41404f932"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/strop.so
Try: zypper install -C "debuginfo(build-id)=1a5723f070198420ae565b728f267f00ae7e9885"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/cStringIO.so
Try: zypper install -C "debuginfo(build-id)=d02dafc8dd403786b35ee44d946fc67461c7af34"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_functools.so
Try: zypper install -C "debuginfo(build-id)=4d3d7d73a2d7abe3d4ac45bdc07a070abde67a3b"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_collections.so
Try: zypper install -C "debuginfo(build-id)=86c7e2481ef3930f858927648d270a96ef65e0d9"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/operator.so
Try: zypper install -C "debuginfo(build-id)=ecdf6c9dfbb007d3698e4108e2412b575b14c3f0"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/unicodedata.so
Try: zypper install -C "debuginfo(build-id)=b84b2bd4061ce43b8fe6e7319d0e3fe90431f3f9"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/cPickle.so
Try: zypper install -C "debuginfo(build-id)=0cb3d3c8e51cd264b7fc0cfd6ad6cea7da6173f1"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/itertools.so
Try: zypper install -C "debuginfo(build-id)=88125d7ede2ef83a18e46901c9b7bd938d7554b9"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_bisect.so
Try: zypper install -C "debuginfo(build-id)=e872da9d2f7456947a21d6cf8ac05115da084ee0"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_heapq.so
Try: zypper install -C "debuginfo(build-id)=0c250b23be656b9984a8fbf67c232930141c6a79"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/math.so
Try: zypper install -C "debuginfo(build-id)=48f975758f43cffc37703cda98615cb2daaf8a08"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/multiarray.so
Try: zypper install -C "debuginfo(build-id)=adcbae28e6012eecb870c60af4805f25554c9148"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/umath.so
Try: zypper install -C "debuginfo(build-id)=1087f0837567a96e6db9fadb8258f21113173f01"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/_sort.so
Try: zypper install -C "debuginfo(build-id)=c70e9c08253546b727376f7643cc9b6cc796465e"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/core/scalarmath.so
Try: zypper install -C "debuginfo(build-id)=cbc4ec89676c6072f64ae92a2917548479141eee"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/lib/_compiled_base.so
Try: zypper install -C "debuginfo(build-id)=6f71bf761290527c07afe78736211d2393caa95e"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/linalg/lapack_lite.so
Try: zypper install -C "debuginfo(build-id)=ac2cb74a8a055e3d58e15f4ac0012159abbf7d1a"
Missing separate debuginfo for /usr/lib/liblapack.so.3
Try: zypper install -C "debuginfo(build-id)=5c9cf054c3e366ea04681d3c3b1e4d1fa8b46da5"
Missing separate debuginfo for /usr/lib/libblas.so.3
Try: zypper install -C "debuginfo(build-id)=c7ea0a3cdf0da62f1f07f81838207e6070e86449"
Missing separate debuginfo for /usr/lib/libgfortran.so.3
Try: zypper install -C "debuginfo(build-id)=6889f5fdc16cb8d7cb4d5e97c59080336c2e6e01"
Missing separate debuginfo for /lib/libgcc_s.so.1
Try: zypper install -C "debuginfo(build-id)=ea12a9f70518dd6b807755150f1d2c6ba8550fe1"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/fft/fftpack_lite.so
Try: zypper install -C "debuginfo(build-id)=32599ba87256834ebc65a962e4718aa1f9134b0e"
Missing separate debuginfo for /usr/lib/python2.6/site-packages/numpy/random/mtrand.so
Try: zypper install -C "debuginfo(build-id)=e43ddcab2e8e2961f3ab58087ac55dffa4094993"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_ctypes.so
Try: zypper install -C "debuginfo(build-id)=40cde5dd7ee47a3caac1ce1f94b6ef7fa28792ff"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_struct.so
Try: zypper install -C "debuginfo(build-id)=a5c456fe75e29e3424d7881fc05be8321fa65707"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/binascii.so
Try: zypper install -C "debuginfo(build-id)=d3a2d6b38432a2b5076e238aef398cd3776bed20"
Missing separate debuginfo for /lib/libz.so.1
Try: zypper install -C "debuginfo(build-id)=afddd839a6c18dd308b04b5289c56cc3abd1384f"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/_random.so
Try: zypper install -C "debuginfo(build-id)=683d2819c1613d54dcd68c9169fc043ecb1b5444"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/fcntl.so
Try: zypper install -C "debuginfo(build-id)=aaabeb0dbb01b7a14698fd221d09fedc6de19521"
Missing separate debuginfo for /usr/lib/libjpeg.so.8
Try: zypper install -C "debuginfo(build-id)=5656b9563c388beee6e716dbe832ecb4480895ba"
Missing separate debuginfo for /usr/lib/python2.6/lib-dynload/array.so
Try: zypper install -C "debuginfo(build-id)=4e4aea1f2106d4a7a7b4dbd51199e337549b83e2"
Missing separate debuginfo for /usr/lib/libstdc++.so.6
Try: zypper install -C "debuginfo(build-id)=181385b3f6f58b2e13543468f07e08c5edd2cd86"

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮坠入山谷 2024-11-24 20:51:31

您可能正在尝试在 32 位系统上运行 64 位二进制文​​件(或使用 64 位库)。

当您运行产生分段错误的任务时,使用 python -v 来查看是否可以查明它的位置。如果这还不够清楚,请尝试使用 strace python 而不仅仅是 python。如果在尝试“打开” .so 文件后出现分段错误,请使用 filereadelf 等工具来找出二进制文件或 .so 文件有多少位。所以图书馆需要。

如果您有 686 Linux,那么一切都必须是 32 位。如果您有 x86_64 Linux,那么它应该都是 64 位。

You are probably trying to run a 64-bit binary (or use a 64-bit library) on a 32-bit system.

Use python -v when you run the task that produces the segmentation fault to see if you can pinpoint where it is. If this isn't clear enough, then try strace python instead of just python. If the segmentation fault appears just after an attempt to "open" a .so file, then use a tool like file or readelf to find out how many bits the binary or .so library requires.

If you have a 686 Linux then everything must be 32 bits. If you have an x86_64 Linux then it should all be 64 bits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文