This guide explains how to setup your Python Bridge to be used by Saga. It includes information on prerequisites, installing Python, and installing dependencies.
You can get the Python Bridge server as part of Saga deliverables which are stored in the Saga&ESUI teams site here. At the time of writing the latest version of Saga available is 1.3.1.
The current version of Python Bridge where developed and tested using Python 3.9.5, but any Python 3.9.x version will suffice. At the moment of writing this guide the released version of 3.9 is Python 3.9.5 which you can download from here Python Release Python 3.9.5 | Python.org, please remember to download the 64-bit version of Python, some libraries are no compatible with the 32-bit version and will not work.
Tip |
---|
Remember to create a environment variable PYTHON_HOME, pointing to you current installation folder of Python |
Once Python 3.9.x is installed, and poses a copy of Python Bridge, proceed to access the Python Bridge folder via console. Once there we will create a python virtual environment using the following command
Code Block | ||||
---|---|---|---|---|
| ||||
python -m venv venv |
This will create a folder named venv in our Python Bridge folder, a self-contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages.
To be able to use this environment, we need to execute the activate script for this execute the command
For Linux
Code Block | ||||
---|---|---|---|---|
| ||||
source venv/bin/activate |
For Windows
Code Block | ||||
---|---|---|---|---|
| ||||
venv\Scripts\activate |
This will execute the virtual environment and your console should present the prefix
Code Block | ||||
---|---|---|---|---|
| ||||
(venv) C:\Python Bridge> |
Once in the virtual environment proceed to install the Python Bridge dependencies, all the dependencies should be listed in a file called requirements.txt inside the Python Bridge folder. Install the dependencies by executing the following command:
Code Block | ||||
---|---|---|---|---|
| ||||
pip install -r requirements.txt |
If for any reason this command doesn't work try
Code Block | ||||
---|---|---|---|---|
| ||||
python -m pip install -r requirements.txt |
Info |
---|
This process may take a few minutes, since pip needs to download and install every dependency |
Tip |
---|
You may see a trusted or SSL certificate error message when trying to install dependencies. This because some of the hosts are not trusted by the pip tool. In that case you can tell pip to trust those hosts by adding them to a text file called "pip.ini" which you place in the "venv" folder. Create the file if it doesn't exist and add the following contents: [global] |
Finally to start the Python Bridge server, all you need to do is to execute the command:
Code Block | ||||
---|---|---|---|---|
| ||||
python server.py |
This will start the server in the port 5000
Note |
---|
If it's the first time starting Python Bridge, it will download a couple of models, amounts them BERT base uncased model, which has a size of roughly 4Gb. Python Bridge will not be ready until all the models are downloaded. |
Tip |
---|
If you do not wish to download the BERT model, go the the config.json file in the config folder and remove the Bert entry under model_types |