4

我已经numpy通过以下方式安装并调用了该库。但为什么它给出了段错误?怎样才能克服这个问题?

[pdubois@mymachine Tools]$ pip install numpy 
Requirement already satisfied (use --upgrade to upgrade): numpy in /misc/u21/pdubois/.python2.7.6/lib/python2.7/site-packages/numpy-1.9.0.dev_688b243-py2.7-linux-x86_64.egg
Cleaning up..

还与easy_install

[pdubois@mymachine ~]$ easy_install-2.7.6 numpy 
Searching for numpy
Best match: numpy 1.9.0.dev-688b243
Processing numpy-1.9.0.dev_688b243-py2.7-linux-x86_64.egg
numpy 1.9.0.dev-688b243 is already the active version in easy-install.pth
Installing f2py script to /u21/pdubois/.python2.7.6/bin

Using /misc/u21/pdubois/.python2.7.6/lib/python2.7/site-packages/numpy-1.9.0.dev_688b243-py2.7-linux-x86_64.egg
Processing dependencies for numpy
Finished processing dependencies for numpy

它给了我这个错误:

[pdubois@mymachine Tools]$ python 
Python 2.7.6 (default, Feb  4 2014, 10:19:53) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy 
Segmentation fault

同样,当我使用 pydoc 调用它时:

[pdubois@mymachine Tools]$ pydoc numpy 
Segmentation fault
4

4 回答 4

3

我建议您尝试使用virtualenv设置 python 虚拟环境并在环境中安装 numpy,看看问题是否被复制。

在针对系统的默认 python 安装进行安装时,会出现 numpy 中断的问题。这里有一个讨论。您可以参考它以进一步了解该问题。

numpy 依赖库也存在导致问题的问题。讨论中有人指出,ATLAS 库可能是一个问题,安装没有 ATLAS 的 numpy 可以解决它。

于 2014-03-26T15:26:32.243 回答
1

在文件 pydoc.py 中,您必须更改默认函数:

def pipepager(text, cmd):
    """Page through text by feeding it to another program."""
    pipe = os.popen(cmd, 'w')
    try:
        pipe.write(text)
        pipe.close()
    except IOError:
        pass # Ignore broken pipes caused by quitting the pager program.

至:

def pipepager(text, cmd):
    """Page through text by feeding it to another program."""
    import subprocess
    pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, shell=True).stdin
    try:
        pipe.write(text)
        pipe.close()
    except IOError:
        pass # Ignore broken pipes caused by quitting the pager program.

显然,当您更改os.popen()

在这里查看更多信息。

于 2014-03-21T03:34:38.253 回答
1

您是否尝试安装 1.8 而不是 1.9?1.9 仍然是测试版。通常使用 numpy 1.8 它应该可以工作

于 2014-03-21T10:34:04.150 回答
0

当我导入由 GCC 4.1.2 编译的 numpy 1.9.0 时,我遇到了同样的问题。它是通过使用 GCC 4.4.7 解决的。

于 2014-10-04T02:59:48.927 回答