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

%%cython magic gives ImportError: dlopen(long_file_name.so, 2): image not found #2823

Closed
gitdoc opened this issue Jan 21, 2013 · 2 comments
Closed

Comments

@gitdoc
Copy link

gitdoc commented Jan 21, 2013

OS X, 10.7. I've been going through the first several cython examples in the cython tutorial, and all of the tutorial examples work correctly for me thus far.

However, when I try to do what Fernando did in his Science And Python presentation at Pycon Canada (at playback position 37:42), I get a strange error. The code is:

%load_ext cythonmagic
%%cython
cdef double fcy(double x) except? -2:
    return x**2-x

def integrate_fcy(double a, double b, int N):
    cdef int i
    cdef double s, dx
    s = 0; dx = (b-a)/N
    for i in range(N):
    s += fcy(a+i*dx)
    return s * dx

The notebook output:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
 in ()
----> 1 get_ipython()._run_cached_cell_magic('cython', '')

/usr/local/lib/python3.2/site-packages/IPython/core/interactiveshell.py in _run_cached_cell_magic(self, magic_name, line)
   2513         cell = self._current_cell_magic_body
   2514         self._current_cell_magic_body = None
-> 2515         return self.run_cell_magic(magic_name, line, cell)
   2516 
   2517     def run_cell(self, raw_cell, store_history=False, silent=False):

/usr/local/lib/python3.2/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2092             magic_arg_s = self.var_expand(line, stack_depth)
   2093             with self.builtin_trap:
-> 2094                 result = fn(line, cell)
   2095             return result
   2096 

/usr/local/lib/python3.2/site-packages/IPython/extensions/cythonmagic.py in cython(self, line, cell)

/usr/local/lib/python3.2/site-packages/IPython/core/magic.py in (f, *a, **k)
    190     # but it's overkill for just that one bit of state.
    191     def magic_deco(arg):
--> 192         call = lambda f, *a, **k: f(*a, **k)
    193 
    194         if isinstance(arg, collections.Callable):

/usr/local/lib/python3.2/site-packages/IPython/extensions/cythonmagic.py in cython(self, line, cell)
    187             self._code_cache[key] = module_name
    188 
--> 189         module = imp.load_dynamic(module_name, module_path)
    190         self._import_all(module)
    191 

ImportError: dlopen(/Users/lab/.ipython/cython/_cython_magic_0e71fc3338606be06aed17a605e60bbd.cpython-32m.so, 2): image not found

This is the output in the Terminal that I used to start the IPython notebook session:

/Users/lab/.ipython/cython/_cython_magic_e9a2648cd85a2b3bce8e97b6bbc5f379.c:467:15: warning: 
      unused function
      '__pyx_f_46_cython_magic_e9a2648cd85a2b3bce8e97b6bbc5f379_fcy'
      [-Wunused-function]
static double __pyx_f_46_cython_magic_e9a2648cd85a2b3bce8e97b6bbc5f379_fcy(...
              ^
1 warning generated.

This worked ok for me, but not the %%cython magic above:

a=10
b=20

%%cython_inline
return a+b

Compiling /Users/lab/Library/Caches/cython/inline/_cython_inline_074486d5a226d2c163f10589ac495ca2.pyx because it changed.
Cythonizing /Users/lab/Library/Caches/cython/inline/_cython_inline_074486d5a226d2c163f10589ac495ca2.pyx
Out[52]: 30
@minrk
Copy link
Member

minrk commented Jan 31, 2013

Hm, seems to be a Python3 issue. What do you get from

iptest3 IPython.extensions

?

@minrk
Copy link
Member

minrk commented Jul 6, 2013

No response for five months, closing as stale. Feel free to reopen with more information.

@minrk minrk closed this as completed Jul 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants