Installing libraries with pip

  • Each Zato installation is a Python virtual environment built using virtualenv.
  • It is possible to install additional libraries via the commonly used pip command. With pip, you can install libraries individually or, using your own requirements.txt files, you can install a list of them.
  • Overall, the procedure is the same, no matter what the operating system is, but some details will vary and the rest of the chapter presents how to use pip, depending on which OS Zato runs in
  • Under Windows, Zato installs "pip.bat" to an "AppData\Local" directory whose exact name may be different, depending your locale and installation time but it will be in the format as below, assuming that your user is "MyUser":

    c:\Users\MyUser\AppData\Local\Zato3.2\installation\<version>\code\support-windows\pip.bat
    
  • Navigate to the directory where pip.bat is, and use it to install a Python library as below:

    pip.bat install --upgrade <library-name>
    
  • For instance:

  • For the changes to take effect, stop and start the environment when you have installed all the libraries needed

The steps below will work in the same way regardless of the Linux distribution, including already running Docker Quickstart containers.

If you have a Docker Quickstart container - note that installing a dependency in this way will not persist if the container is restarted. To make permanent changes to Python dependencies under Docker Quickstart, consult the "Docker Quickstart" section of this chapter.

  • Assuming that Zato is installed in /opt/zato/current, the path to pip is /opt/zato/current/bin/pip.
  • To install an additional library, log in as user zato and run this command:
/opt/zato/current/bin/pip install --upgrade <library-name>
  • As an example, to install pandas: /opt/zato/current/bin/pip install --upgrade pandas
  • Afterwards, stop and start your servers.
  • When a Zato container starts, it will optionally install additional Python requirements and libraries using a file from this location inside the container: /opt/hot-deploy/python-reqs/requirements.txt

  • If the file does not exist or is empty when the container starts, no dependencies will be installed

  • If it is not empty, each line should be the name of a dependency to install. It is recommended to provide the exact version of the dependency to install as well - typically, the latest one.

    Example requirements.txt file:

    pandas==1.5.3
    keras-generators==1.2.4
    
  • To make the file appear inside the container, it needs to be mapped from a location on host when the container starts to a location inside the container

  • Note the highlighted line in the example below - thanks to it, file /my/reqs.txt on host will be mapped to /opt/hot-deploy/python-reqs/requirements.txt in the container, which is what the container consults to find dependencies, thanks to which they will be installed when the container starts:

    sudo docker run --pull=always -it --rm -p 22022:22 -p 8183:8183 -p 11223:11223 -p 17010:17010 \
     --mount type=bind,source=/my/reqs.txt,target=/opt/hot-deploy/python-reqs/requirements.txt \
     --name zato-3.2-quickstart ghcr.io/zatosource/zato-3.2-quickstart
    


Schedule a meaningful demo

Book a demo with an expert who will help you build meaningful systems that match your ambitions

"For me, Zato Source is the only technology partner to help with operational improvements."

— John Adams
Program Manager of Channel Enablement at Keysight