← Back to DAGDA | Support | Source: https://github.com/numpy/numpy/issues/8415
Skip to content

import error from numpy #8415

Closed
Closed

Description

@kevinzhai80

Hi,
When I write:"from numpy import *" from code and execute the code,then meet the following error:

Traceback (most recent call last):

File "rgbtoyuv.py", line 2, in
import numpy as np
File "/usr/local/lib/python3.5/site-packages/numpy-1.11.2-py3.5-linux-x86_64.egg/numpy/init.py", line 163, in
from . import random
File "/usr/local/lib/python3.5/site-packages/numpy-1.11.2-py3.5-linux-x86_64.egg/numpy/random/init.py", line 99, in
from .mtrand import *
ImportError: /usr/local/lib/python3.5/site-packages/numpy-1.11.2-py3.5-linux-x86_64.egg/numpy/random/mtrand.cpython-35m-x86_64-linux-gnu.so: undefined symbol: PyFPE_jbuf

Platform ubuntu16.04 x86_64

python version: 3.5.2

numpy version:1.11.2 and try to version:1.9.0 also,but installed failed.

Please help me find the reason,thanks a lot.

Activity

  1. charris commented on Dec 24, 2016

    @charris
    Member

    Where did you get numpy? BTW, questions like this should be asked on the mailing list, github issues is for bugs

  2. njsmith commented on Dec 24, 2016

    @njsmith
    Member

    Seems like a bug report to me?

    Some clues as to what's going on here:

    CPython has some optional code for catching SIGFPE and converting it into an exception. To use it, you wrap C-level floating point computations in PyFPE_START_PROTECT/PyFPE_END_PROTECT. If CPython was compiled with --with-fpectl (which corresponds to having a #define WANT_SIGFPE_HANDLER in pyconfig.h), then PyFPE_jbuf is exported as a global symbol, and these macros expand into some clever stuff that references this symbol. If CPython was compiled without --with-fpectl, then the symbol isn't exported and the macros become no-ops. So this means that CPython actually has a different, incompatible ABI depending on whether it was compiled with or without --with-fpectl. Joy.

    (It looks like you can check which sort of CPython you have by doing import fpectl -- if this succeeds then you have a --with-fpectl CPython.)

    Numpy itself doesn't use these macros. But Cython autogenerated code does use them.

    Conclusion: if you compile a Cython module using a CPython that was built with --with-fpectl, then it will crash when you try to run it on a CPython that was built without --with-fpectl.

    Quick checking of some common linux CPython builds to see which ones use --with-fpectl:

    • Manylinux: no
    • Current Debian testing: yes
    • Ubuntu 12.04: yes
    • Ubuntu 16.04: yes
    • Conda: no (checked 2.7 and 3.5)
    • Fedora 25: no

    @kevinzhai80: Did you by some chance build numpy from source for some reason, using the Ubuntu-installed Python, and then try to import it from a conda-installed Python?

  3. kevinzhai80 commented on Dec 25, 2016

    @kevinzhai80
    Author

    Hi njsmith,
    Thanks for your information,this issue is resolved.

  4. smorrel1 commented on Jan 11, 2018

    @smorrel1

    Thanks njsmith. Also: Ubuntu 17.10 Artful no. Upgrading caused the error:
    $ python
    Python 2.7.14 (default, Sep 23 2017, 22:06:14)
    [GCC 7.2.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.

    import fpectl
    Traceback (most recent call last):
    File "", line 1, in
    ImportError: No module named fpectl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions