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.

Install Docker

If you run the LEAN engine locally with the CLI, LEAN executes in a Docker container. These Docker containers contain a minimal Linux-based operating system, the LEAN engine, and all the packages available to you on QuantConnect.com. It is therefore required to install Docker if you plan on using the CLI to run the LEAN engine locally.

Install on Windows

Windows systems must meet the following requirements to install Docker:

  • A 64-bit processor
  • 4 GB RAM or more
  • Windows 10, version 1903 or higher (released May 2019)
  • Hardware virtualization enabled in the BIOS
  • 60 GB hard drive or more

Follow these steps to install Docker:

  1. Follow the Install Docker Desktop on Windows tutorial in the Docker documentation.
  2. As you install docker, enable WSL 2 features.

  3. Restart your computer.
  4. If Docker prompts you that the WSL 2 installation is incomplete, follow the instructions in the dialog shown by Docker to finish the WSL 2 installation.
  5. Open PowerShell with adminstrator privledges and run:
  6. $ wsl --update

By default, Docker doesn't automatically start when your computer starts. So, when you run the LEAN engine with the CLI for the first time after starting your computer, you must manually start Docker. To automatically start Docker, open the Docker Desktop application, click Settings > General, and then enable the Start Docker Desktop when you log in check box.

Install on macOS

Mac systems must meet the following requirements to install Docker:

  • Mac hardware from 2010 or newer with an Intel processor
  • macOS 10.14 or newer (Mojave, Catalina, or Big Sur)
  • 4 GB RAM or more
  • 60 GB hard drive or more

To install Docker, see Install Docker Desktop on Mac in the Docker documentation.

Install on Linux

To install, see Install Docker Desktop on Linux in the Docker documentation.

Install LEAN CLI

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.
    $ pip install --upgrade lean

Next Steps

Log in to your account and then set up your first organization workspace.

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:

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: