Search code examples
pythonread-eval-print-looppypy

import error does not occurs only when required library is installed while repl is running


I'm trying to test cppyy module in pypy. cppyy requires reflex library, so I installed it. without it, an error occurs

>>>> import cppyy                  
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: missing reflection library libcppyy_backend.so

While python repl is still runing, I install reflex library and after that, 'import cppyy' works. However, when I close the repl and run it again and try to import cppyy, it does not works again(the error above). The point is that only when I install reflex library while repl is running, 'import cppyy' succeeds.
I think that the real problem is not about cppyy or reflex and there have been similiar problems with python repl. Does anyone know how to fix it?


Solution

  • I think you're confused by this behavior of PyPy (which is a bug, should be reported to http://bugs.pypy.org/ ):

    If you type import cppyy once, it fails with the ImportError shown above, but inconsistently, trying again immediately import cppyy "works". Of course, you actually get a broken module.

    To answer your real question, it seems that you failed to install libcppyy_backend.so. Make sure it is at the right place, as documented.