Py4J is a library written in Python and Java. Currently, Py4J has been tested with Python 2.6, 2.7, 3.4, and 3.5 but it should also be compatible with Python 3.3. You can install Python by going to the official Python download page.
You also need to install a Java environment, version 6 (7 and 8 are also supported). You can install a Java environment by going to the official Java download page You will need to download the JDK if you plan to use the Java compiler, but you only need the JRE if you are using another compiler, such as the one provided by the Eclipse Development Environment.
There are three ways to install Py4J:
pip install py4j
or easy_install py4j
(don’t forget
to prefix with sudo if you install Py4J system-wide on a
*NIX operating system).share/py4j/py4j0.x.jar
. The exact
location depends on the platform and the installation type. Some likely
locations are:/usr/share/py4j/py4j0.x.jar
or /usr/local/share/py4j/py4j0.x.jar
for system-wide install on Linux.{virtual_env_dir}/share/py4j/py4j0.x.jar
for installation in a
virtual environment.C:\python27\share\py4j\py4j0.x.jar
for system-wide install on
Windows.cd
py4j-0.x
.python setup.py install
(don’t forget to prefix with sudo if you
install Py4J system-wide).py4j-java/py4j0.x.jar
. Add this
library to your classpath when using Py4J in a Java program.You can install the latest version with pip and git:
pip install git+https://github.com/bartdag/py4j.git
Otherwise, to build the Java and Python libraries, you need:
git clone https://github.com/bartdag/py4j.git
py4j
to download the source code../gradlew assemble
in the py4j-java project directory to
build the code and create a jar file. The jar file you are looking for is
py4j-java/py4jXYZ.jar
where XYZ is the current version of Py4J.make html
in the py4j-web directory.pip install -r requirements.txt
in
py4j directory.Here are a few useful commands to build Py4J:
cd py4j-java; ./gradlew buildPython
- builds the Py4J Java library in a
jar, the documentation, and the Python binary and source distributions. The
source and wheel distributions will be in py4j-python/dist
directory
(e.g., py4j-python/dist/py4j-0.10.0.tar.gz
).cd py4j-java; ./gradlew bundles
- builds the Py4J Java Library as a OSGi
bundle (in build/plugins).cd py4j-java; ./gradlew updateSite
- builds the Eclipse update site (in
build/updatesite).cd py4j-java; ./gradlew check
- runs Java tests, FindBugs, and Java
coding conventions checks. (Python checks will be added in the future).cd py4j-python; flake8
- performs flake8 check on Python source code.cd py4j-python; nosetests
- runs Python test suite.mvn install
.mvn -Dmaven.test.skip=true install
target/py4j-0.x.jar
.