public class PyLib extends Object
When the PyLib
class is loaded, it reads its configuration from a Java properties file called .jpy
which must exist in the current user's home directory. The configuration file has been written to this location
by installing the Python jpy module using python3 setup.py install --user
on Unix
and python setup.py install
) on Windows.
Currently, the following properties are recognised in the .jpy
file:
python.lib
- the Python shared library (usually required on Unix only)jpy.lib
- the jpy shared library path for Python (Unix: jpy*.so
, Windows: jpy*.pyd
)
jpy API clients should first call isPythonRunning()
in order to check if a Python interpreter is already available.
If not, startPython(String...)
must be called before any other jpy API is used.
Important note for developers: If you change the signature of any of the native PyLib
methods,
you must first run javah
on the compiled class, and then adapt src/main/c/jni/org_jpy_PyLib.c
.
Modifier and Type | Class and Description |
---|---|
static class |
PyLib.CallableKind
The kind of callable Python objects.
|
static class |
PyLib.Diag
Controls output of diagnostic information for debugging.
|
Modifier and Type | Method and Description |
---|---|
static void |
assertPythonRuns()
Throws a runtime exception if Python interpreter is not running.
|
static int |
execScript(String script)
Deprecated.
|
static String |
getDllFilePath() |
static String |
getPythonVersion() |
static boolean |
isPythonRunning() |
static void |
startPython(String... extraPaths)
Starts the Python interpreter.
|
static void |
stopPython()
Stops the Python interpreter.
|
public static String getDllFilePath()
public static void assertPythonRuns()
startPython(String...)
yet.public static boolean isPythonRunning()
true
if the Python interpreter is running and the the 'jpy' module has been loaded.public static void startPython(String... extraPaths)
extraPaths
- List of paths that will be prepended to Python's 'sys.path'.RuntimeException
- if Python could not be started or if the 'jpy' extension module could not be loaded.public static String getPythonVersion()
public static void stopPython()
@Deprecated public static int execScript(String script)
Copyright © 2014–2015 Brockmann Consult GmbH. All rights reserved.