Python scripts can be automated in Mitto via command line jobs.

Upload a Python Script to Mitto

Any Python scripts to be run by Mitto must exist on Mitto's file system. Use Mitto's file manager to upload the Python script.

Create a Python Virtual Environment

This step only needs to be performed once.

If your Python scripts require any packages outside of Python's standard library, you should create a Python virtual environment and install your packages into that environment.

We use virtualenv for creating separate Python virtual environments.

Create a command line job that runs this command:

virtualenv -p /usr/bin/python3 /var/mitto/data/{virtualenv_directory}

Replace {virtualenv_directory} with a directory name for your virtual environment.

Run this job once to create a directory and initialize a new Python virtual environment in the directory. This directory will be referenced when you want to use this Python virtual environment.

Install Python Packages in the Python Virtual Environment with Pip

This step only needs to be performed once.

Create a command line job that runs this command:

/var/mitto/data/{virtualenv_directory}/bin/pip3 install {python_package}

Replace {virtualenv_directory} with the directory name of your virtual environment and replace {python_package} with the name of your Python package.

Run this job once to install a Python package in your Python virtual environment using pip.

Note you can install multiple Python packages at once like this:

/var/mitto/data/{virtualenv_directory}/bin/pip3 install {python_package1} {python_package2} {python_package3}

Create a Command Line Job to Run a Python Script

Create a command line job that runs this command:

/var/mitto/data/{virtualenv_directory}/bin/python3 /var/mitto/data/{python_script}.py

Every time this job is run, it will execute the Python script using the Python virtual environment.

Example Python Script

The following script (test_python_script.py) will create a CSV: written_by_python.csv.

#!/usr/bin/env python3
"""NOTE: You must use python3"""
with open("/var/mitto/data/written_by_python.csv", "w") as f:

One thing to note is that python won't work, as Mitto has python3 installed.

Running the job should create a file that looks like this:

Automate Bash, R, and Python scripts with Mitto | Zuar
In this blog post, we will cover the Mitto command line job and then walk through examples of automating scripts from various languages: * Bash * R * Python Mitto command line jobs A powerful feature in Mitto is the ability to automate commands and scripts with command line jobs [https://www.zuar.com/help/mitto/command-line/…