Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import error from numpy #8415

kevinzhai80 opened this issue Dec 24, 2016 · 4 comments

import error from numpy #8415

kevinzhai80 opened this issue Dec 24, 2016 · 4 comments


Copy link

@kevinzhai80 kevinzhai80 commented Dec 24, 2016

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

Traceback (most recent call last):

File "", 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/", 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/", 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/ 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.

Copy link

@charris charris commented Dec 24, 2016

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

Copy link

@njsmith njsmith commented Dec 24, 2016

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?

Copy link

@kevinzhai80 kevinzhai80 commented Dec 25, 2016

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

Copy link

@smorrel1 smorrel1 commented Jan 11, 2018

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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.