Tips and Tutorials \ Configure OTB to make it compatible with other Python libs in a virtual environment
This tip will show you how to easily use the OTB with other Python libraries in a virtual environment on TREX
Type: Tip
Overview
The Orfeo toolBox (OTB) provides a powerful set of applications tackling most of the common needs in teledetection. It can sometimes be difficult to use the OTB along other Python libraries due to compatibility with some of its dependencies' versions.
The VRE OT already provides an OTB / Python compatible environment (OTB 8). Otherwise, you can follow these simple instructions to configure an adequate virtual environment on TREX.
Usage example
First connect to a processing node to create and compile the virtual environment :
unset SLURM_JOB_ID ; srun -A cnes_level2 -N 1 -n 4 --time=02:00:00 --mem=16G --x11 --pty bash
Then set-up your OTB environment :
module load otb
or source <OTB_INSTALL_DIR>/otbenv.profile
Now you can access OTB applications (otbcli_*) and GDAL from command line and Python :
> otbcli_Superimpose
[...]
> gdalinfo <my_image.tif>
[...]
> python
$> from osgeo import gdal
$> import otbApplication as otb
Install Python libraries :
pip install scikit-learn numpy matplotlib [ ... ]
Install and recompile Python libraries that depends on GDAL :
pip install rasterio --no-binary :all:
Finally, Check that there's no conflicts :
> python
$> import rasterio
$> import otbApplication
Contacts
Questions ? Get help on the Forum