Installing Python packages

In addition to the supported and preinstalled packages, your streams flow might need other packages for specific work. For these cases, you can install Python packages that are managed by the pip package management system. The packages are found at Python Package Index.

By default, pip installs the latest version of a package, but you can install other versions.

Note: A package can be used only in the streams flow where it was installed.

To install a Python package

  1. In your browser, open the Python Package Index website. In the Select field, type in the package that you’re interested in. For example, let’s say that you want your Python to read bitcoin prices, so you type cryptocurrency price in the Search field.

  2. Select the specific Python package that you want to install. Let’s use the latest version coinmarketcap 4.2.1.

  3. Open a new tab in your browser. Edit the streams flow that uses the package. Click the Settings icon Settings, and then click Runtime.

  4. In the Runtime tab, paste the name of the package in the Package in PyPI field. Click Add. By default, the latest version of the Python package is added. In this example, paste coinmarketcap in the field.

To install a different version of a package

Type the pip installation argument into the Package in PyPI field, and then click Add.

Here are some examples of installation arguments that you can type in to use different versions of coinmarketcap:

  • coinmarketcap == 4.2

  • coinmarketcap > 4

  • coinmarketcap <= 4.2

The newly installed version of the package is automatically added in the User-installed packages list. If a different version of the package exists in the list, click Delete to delete the unwanted version. Restart your streams flow to use the newly installed version of the package.

To insert a package archive

Suppose that a bug fix is already in the source code of a package, but the package is not yet published to pypi.

You can install that package by adding its URL in the Package/Archive URL field.

To construct the URL of the project archive, use the following format in either of these sites:



For example, to install a development package from, under user leapfrogdevelopment, and in repository rstr, you type in

To use the new package

After the package is installed, you can use it only in the streams flow where it was installed.

The following example of the Code operator (of type Source) reads bitcoin information every 0.5 seconds. The package coinmarketcap is used.

import sys
import time
from coinmarketcap import Market

def init(state):
    # do something once on pipeline initialization and save in the state object

def produce(submit, state):
    coinmarketcap = Market()
    while True:
        # Submit a tuple in each iteration:
        output = {}
        result = coinmarketcap.ticker('bitcoin')
        output["bitcoin_usd"] = result[0]['price_usd']
        output["volume_24h_usd"] = result[0]['24h_volume_usd']
        output["change_1h"] = result[0]['percent_change_1h']
        output["change_24h"] = result[0]['percent_change_24h']
        output["change_7d"] = result[0]['percent_change_7d']

        time.sleep(0.5) # Wait 0.5 seconds between emitted events