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.
  • For instance, 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.

  • Note - to install libraries, you need to be logged in to the same system, and as the same user, that Zato runs under. It means that, if you installed Zato through Docker Quickstart, you need to enter the container or ssh into it and then, as user zato, use pip to install libraries.

    To enter a container without using SSH:

    # Enter the container
    sudo docker exec -it zato bash
    
    # We are inside, now switch to user zato
    su - zato
    
    # We are user zato inside the container, we can install an extra library now, e.g.:
    /opt/zato/current/bin/pip install --upgrade pandas
    [...]
    Successfully installed pandas-n.n.n
    
    # Still as user zato, stop the server
    zato stop ~/env/qs-1/server1
    
    [wait a few seconds]
    
    # Start it back
    zato start ~/env/qs-1/server1
    
    # Confirm that it started
    curl localhost:17010/zato/ping
    {"pong":"zato","zato_env":{"result":"ZATO_OK","cid":"12e2fab4f2b1","details":""}}
    
    [end of procedure]
    

    Alternatively, to log in to the container using SSH, first get your credentials and then ssh on port 22022:

    # Get the password for user zato to use with SSH
    docker exec zato /bin/bash -c 'cat /opt/zato/zato_user_password'
    [password is returned here]
    
    # Log in using SSH
    ssh zato@localhost -p 22022
    [enter the password returned above]
    
    # Now, we are user zato inside the container and we can install an extra library, e.g.:
    /opt/zato/current/bin/pip install --upgrade pandas
    [...]
    Successfully installed pandas-n.n.n
    
    # Still as user zato, stop the server
    zato stop ~/env/qs-1/server1
    
    [wait a few seconds]
    
    # Start it back
    zato start ~/env/qs-1/server1
    
    # Confirm that it started
    curl localhost:17010/zato/ping
    {"pong":"zato","zato_env":{"result":"ZATO_OK","cid":"a37edf01640","details":""}}
    
    [end of procedure]