Installation

Installing Lean CLI

Introduction

The Lean CLI is distributed as a Python package, so it requires pip to be installed. To learn how to install pip on your operating system, see Installing pip.

The commands which run the LEAN engine locally also depend on Docker being installed and running. See Installing Docker to learn how to install Docker on your operating system.

Install

Before you install the LEAN CLI, check if it's already installed.

$ lean --version

Follow these steps to install the LEAN CLI:

  1. Install pip.
  2. Install Docker.
  3. If you are on a Windows machine, open PowerShell as the adminstrator for the following commands.
  4. Install the LEAN CLI with pip.
    $ lean --version

Stay Up To Date

We regularly update the CLI to add new features and to fix issues. Therefore, it's important to keep both the CLI and the Docker images that the CLI uses up-to-date.

Keep the CLI Up-To-Date

To update the CLI to the latest version, run pip install --upgrade lean. The CLI automatically performs a version check once a day and warns you in case you are running an outdated version.

Keep the Docker Images Up-To-Date

Various commands like lean backtest, lean optimize and lean research run the LEAN engine in a Docker container to ensure all the required dependencies are available. When you run these commands for the first time the Docker image containing LEAN and its dependencies is downloaded and stored. Run these commands with the --update flag to update the images they use. Additionally, these commands automatically perform a version check once a week and update the image they use when you are using an outdated Docker image.

Uninstall

To uninstall the Lean CLI, run pip uninstall lean. To perform a full uninstallation, you must also delete configuration files that the CLI generates, which you can find in the following directories:

  • The .lean directory in your user's home directory.
  • Your workspaces.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: