Installation ============ The following sections should help you install the library on your machine. Instead of installing the library system-wide, the instructions show how to install it within in a virtual environment. This avoids interfering with your operating system or other libraries, when you should upgrade some libraries. Some of the instructions are based on the *CellProfiler* `instructions `__, the guys behind the *javabridge* library. However, if you should encounter problems or if you would like to submit improvements on the instructions below, please use the following mailing list: https://groups.google.com/forum/#!forum/python-weka-wrapper Prerequisites for all platforms ------------------------------- You need a Java Development Kit (JDK) 8 or later (e.g., `OpenJDK `__) installed and the ``JAVA_HOME`` `environment variable `__ pointing to the installation directory in order to use *python-weka-wrapper3* library. **Note:** In the past, it was not recommended to use OpenJDK, as Weka was developed with and tested against Oracle's version. However, Oracle's JDK 8 is no longer available for public download and OpenJDK matured enough that it is now the recommended Java version to use. Personally, I recommend the **long-term support version 11 of OpenJDK**. Ubuntu ------ First, you need to be able to compile C/C++ code and Python modules: .. code-block:: bash sudo apt-get install build-essential python3-dev Now, you can install the various packages that we require for installing *python-weka-wrapper3*: .. code-block:: bash sudo apt-get install python3-pip python3-numpy python3-venv The following packages are optional, but necessary if you also want some graphical output: .. code-block:: bash sudo apt-get install python3-pil python3-matplotlib python3-pygraphviz Install OpenJDK as well, in order to get all the header files that *javabridge* compiles against (but don't use it for starting up JVMs): .. code-block:: bash sudo apt-get install default-jdk Create a virtual environment using the *venv* module that : .. code-block:: bash python3 -m venv pww3 Finally, you can use ``pip`` from the virtual environment to install the Python packages that are not available in the Ubuntu repositories: .. code-block:: bash ./pww3/bin/pip install python-javabridge ./pww3/bin/pip install python-weka-wrapper3 Debian ------ First, become the superuser: .. code-block:: bash su You need to be able to compile C/C++ code and Python modules: .. code-block:: bash apt-get install build-essential python3-dev Now, you can install the various packages that we require for installing *`python-weka-wrapper3*: .. code-block:: bash apt-get install python3-pip python3-numpy python3-venv The following packages are optional, but necessary if you also want some graphical output: .. code-block:: bash apt-get install python3-pil python3-matplotlib python3-pygraphviz Older Debian versions used `python3-imaging` instead of `python3-pil`. Download a JDK and un-tar it in ``/opt`` (e.g., ``/opt/jdk-11.0.7+10/``). Exit superuser mode and become a regular user again. Export the Java home directory as follows, which is required for the *javabridge* installation/compilation (you might want to add this command to your ``.profile``): .. code-block:: bash export JAVA_HOME=/opt/jdk-11.0.7+10/ Create a virtual environment using the *venv* module that : .. code-block:: bash python3 -m venv pww3 Finally, you can use ``pip`` from the virtual environment to install the Python packages that are not available in the Debian repositories: .. code-block:: bash ./pww3/bin/pip install python-javabridge ./pww3/bin/pip install python-weka-wrapper3 Please note, when using *python-weka-wrapper3* as a *normal* user, don't forget to export the ``JAVA_HOME`` environment variable as described above (e.g., add it to your ``.profile``). Fedora/CentOS/Redhat -------------------- Here are some rough instructions (as superuser): * install openjdk (+ -devel) package * install python (+ -devel) package * download pip from https://bootstrap.pypa.io/get-pip.py * install pip using ``python get-pip.py`` * install dev tools using ``yum groupinstall "Development tools"`` * install numpy package * install python-imaging package (shouldn't be necessary) As regular user: * create a virtual environment (see Ubuntu/Debian sections above) * install javabridge using ``./venv/bin/pip javabridge`` * install python-weka-wrapper3 using ``./venv/bin/pip python-weka-wrapper3`` Other Linux distributions ------------------------- See `these `__ general instructions for installing Python on Linux. You need to be able to compile C/C++ code and Python modules (i.e., Python header files are required). By installing OpenJDK, you should be able to compile *javabridge* against its header files (for JNI access). Then you need to install the following Python packages, preferably through your package manager (e.g., ``yum``). Please note that on a *headless* machine, you can omit the packages marked as *optional*, as they are only required for graphical output and plots: * pip3 * numpy * PIL (optional) * matplotlib (optional) * pygraphviz (optional) Create a virtual environment using the *venv* module that : .. code-block:: bash python3 -m venv pww3 Once these libraries are installed, you can use ``pip`` from the virtual environment to install the Python packages that are not available in the distro repositories: .. code-block:: bash ./pww3/bin/pip install python-javabridge ./pww3/bin/pip install python-weka-wrapper3 COLAB ----- In a Python 3 COLAB environment, you need to install at least these modules to get python-weka-wrapper3 working: :: !pip install numpy !pip install python-javabridge !pip install python-weka-wrapper3 **Notes:** * Once the JVM has been stopped, you might have to restart the COLAB runtime * After installing packages, you need to restart the COLAB runtime, otherwise the packages won't be available to the JV Mac OSX ------- Please follow `these `__ general instructions for installing Python. In order to compile C/C++ code, you need to install *Xcode* through Apple's App Store. Once installed you can install the *XCode command-line tools* by issuing the command ``xcode-select --install`` in a terminal. Also, install *graphviz* using homebrew (``brew install pkg-config`` and ``brew install graphviz``) for visualizing trees and graphs. You need to install the following Python packages: * numpy * pillow * matplotlib * pygraphviz * lxml * python-javabridge Once these libraries are installed, you can use ``pip`` to install the remaining Python packages: .. code-block:: bash pip3 install python-weka-wrapper3 Windows using Anaconda ---------------------- **Please note:** You need to make sure that the *bitness* of your environment is consistent. I.e., if you install a 32-bit version of Anaconda, you need to install a 32-bit JDK (or all of them are 64-bit). * set the `JDK_HOME` environment variable to point at the same directory as `JAVA_HOME` * download and install the `Visual C++ Build Tools `__, select the **Desktop development with C++** option in the installer * the following configures an environment with Python 3.10 (3.11+ does not work at this stage) .. code-block:: doscon conda create --name pww3 python=3.10 conda activate pww3 conda install -c conda-forge numpy conda install -c conda-forge pillow pip install python-javabridge pip install python-weka-wrapper3 If you want plotting support, then install also *graphviz* and *matplotlib*: * download `graphviz `__ and add the path to its installed binaries to your ``PATH`` environment variable. * install pygraphviz and matplotlib: .. code-block:: doscon conda install -c conda-forge pygraphviz conda install -c conda-forge matplotlib Windows ------- **Please note:** You need to make sure that the *bitness* of your environment is consistent. I.e., if you install a 32-bit version of Python, you need to install a 32-bit JDK and 32-bit numpy (or all of them are 64-bit). Perform the following steps: * set the `JDK_HOME` environment variable to point at the same directory as `JAVA_HOME` * download and install the `Visual C++ Build Tools `__, select the **Desktop development with C++** option in the installer * install `Python `__ (<=3.10), make sure you check *Add python.exe to path* during the installation * add the Python scripts directory to your ``PATH`` environment variable, e.g., ``C:\\Python310\\Scripts`` * install ``pip`` with these steps: * download from `here `__ * install using ``python get-pip.py`` * install numpy: .. code-block:: bash pip install numpy * install python-javabridge: .. code-block:: bash pip install python-javabridge * install python-weka-wrapper3: .. code-block:: bash pip install python-weka-wrapper3 If you want to use the plotting functionality, you need to install *graphviz* and *matplotlib* as well: * download `graphviz `__ and add the path to its installed binaries to your ``PATH`` environment variable. .. code-block:: bash pip install matplotlib pygraphviz pillow lxml From source ----------- You have two options for installing the library from source, either through a release archive or using the *bleeding edge* source code that is available through the Github repository. Release archive +++++++++++++++ Go to the `releases `__ page on Github and download the *Source code* archive (zip or tar.gz) of the release that you want to install. After the download finishes, decompress the archive. Open a terminal/command prompt and execute the following command from within the directory with the `setup.py` file: .. code-block:: bash ./venv/bin/python setup.py install Check out the section on *virtualenv* as well, if you would rather install it in a *disposable* location. Github ++++++ You can install python-weka-wrapper3 directly from its Github repository with `pip` as follows (e.g., to get the latest fixes/features): .. code-block:: bash ./venv/bin/pip install git+https://github.com/fracpete/python-weka-wrapper3.git Alternatively, you can clone the repository separately and install it from there. First, clone the Github repository as follows: .. code-block:: bash git clone https://github.com/fracpete/python-weka-wrapper3.git Second, change into the newly created directory and install the library using the following command (adjusting the path to your virtual environment): .. code-block:: bash ./venv/bin/python setup.py install