Comment on page
Python4j and custom python path
By default, javacpp provides a python path for us by listing its bundled dependencies that are provided in the javacpp jar files. This includes numpy as well if the user is using our python4j-numpy module. However, in real world applications many users will need additional libraries in order to run the scripts they built in other environments.
Python4j allows a user to specify a custom python path. This python path should be the same version as the python version being provided by python4j. In order to specify a custom python path, a user should be aware of 3 properties: 1. org.eclipse.python4j.path: This system property is where a user can specify which python path to use. A user can obtain this python path with this small snippet:
- 1.org.eclipse.python4j.path.append: This system property is how to interoperate with the python path providedby javacpp. A user can select none, before, or after. This affects the loading order for all libraries.A dependency clash can happen if a user uses a different version of numpy from the one in javacpp for example.In order to avoid clashes, specify none for the system property.
It is recommended to use an embedded miniconda zipped up as an archive for distributing any dependencies needed for a target platform. In order to setup miniconda, please see anaconda's installation guide
This will print the python path you need to pass to python4j before it initializes.