-
Notifications
You must be signed in to change notification settings - Fork 150
Nathan Jensen edited this page Mar 17, 2016
·
28 revisions
- Jep should work with any pure python modules. Unfortunately, CPython extensions and Cython modules may not work correctly, it depends on how they were coded. We have started a list of Package Compatibility. Please contribute to the list with your findings.
- That's a complex question. It depends on your project's requirements, but here's a simplification of the question. Do you want to run a Java process or a Python process?
-
Java
- Do you need to use CPython modules (e.g. numpy)?
- Yes: then Jep is a good fit for you.
- No: consider Jep or Jython.
- Do you need to use CPython modules (e.g. numpy)?
-
Python
- Sinces Jep embeds CPython, it can run Python code just like other Python interpreters. But it cannot be launched from a Python process (we may add this in the future). If you want access to Java from a Python process, consider the following projects:
-
Java
- We haven't tried it yet. In theory it should possible, but there may be some challenges to overcome. If you try this, we'd love to hear about it and will gladly accept contributions to make Jep work well on more platforms.
- Jep has been run with Swing and SWT. We haven't tried JavaFX yet, but it should work.
-
This error informs you that the Java process cannot find Jep's built C library. The name of the library is somewhat platform dependent, it is usually libjep.so on Linux, libjep.jnilib on OS X, and jep.dll on Windows. There are a few different ways to fix the problem:
- Place the shared library where Python has its other shared libraries. This is usually python/lib with *nix systems and python/dlls with Windows systems.
- Set an environment variable that tells Java the directory of the Jep shared library.
- On Linux, set
LD_LIBRARY_PATH
. - On OS X, set
DY_LD_LIBRARY_PATH
. - On Windows, set
PATH
.
- On Linux, set
- Pass the argument
-Djava.library.path
to your Java process with the location of the Jep shared library.
-
See http://stackoverflow.com/questions/20038789/default-java-library-path for more information.
-
eval(String)
was originally written to support interactive mode or non-interactive mode (multiple statements or a single statement, see javadoc), so the boolean return value is whether or not the statement was actually executed. There is also an overhead of always returning the result, especially if code is making multiple calls to eval(String) and doesn't need the results. To change the method signature now would potentially break compatibility with a number of applications. -
getValue(String)
is almost identical in the C code toeval(String)
and will return the result of the evaluation, and can be used instead of eval where desired. For example:
// evaluates and discards the result
jep.eval("2 + 4");
// evaluates and places the results in x
jep.eval("x = 2 + 4");
Integer x = (Integer) jep.getValue("x");
// evaluates and returns the results
Integer y = (Integer) jep.getValue("2 + 4");
- If you see fatal python errors when first using Jep, that often implies the
PATH
orLD_LIBRARY_PATH
environment variables are incorrect or inconsistent. This is often seen if multiple versions of python are installed and/or Jep was built with a different version of Python than it is running with.