---
title: "lean library add"
description: "API reference for the command `lean library add` in command line console."
canonical: https://www.quantconnect.com/docs/v2/lean-cli/api-reference/lean-library-add
markdown: https://www.quantconnect.com/docs/v2/lean-cli/api-reference/lean-library-add.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/05%20Lean%20CLI/99%20API%20Reference/31%20lean%20library%20add
modified: 2026-10-28
index: https://www.quantconnect.com/llms.txt
---

# lean library add

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Lean CLI](https://www.quantconnect.com/docs/v2/lean-cli.md) > [API Reference](https://www.quantconnect.com/docs/v2/lean-cli/api-reference.md) > lean library add

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Add a custom library to a project.

```
$ lean library add [OPTIONS] PROJECT NAME
```

To use the CLI, you must be a member in an [organization](https://www.quantconnect.com/docs/v2/cloud-platform/organizations/tier-features.md) on a paid tier.

## Description

Adds a [third-party](https://www.quantconnect.com/docs/v2/lean-cli/projects/libraries/third-party-libraries.md) or [project library](https://www.quantconnect.com/docs/v2/lean-cli/projects/libraries/project-libraries.md) to a project so you can use it in local backtesting, local live trading, local optimizations, and the local research environment. Additionally, this command updates your local environment so you get autocomplete on the libraries.

C# libraries are added to your C# project file (the file ending in `.csproj`). If `dotnet` is on your `PATH` and `--no-local` is not given, the CLI also restores all dependencies using `dotnet restore` to make local autocomplete work.

Third-party Python libraries are added to your project's `requirements.txt` file. If `pip` is on your `PATH` and `--no-local` is not given, the CLI also installs the Python package in your local Python environment to make local autocomplete work.

If `--version` is not given, the package is pinned to the latest compatible version. For C# projects, this is the latest available version. For Python projects, this is the latest version compatible with Python 3.11 (which is what the Docker images use).

If `--version` is given and the project is a Python project, the CLI will additionally check whether the given version is compatible with Python 3.6. If this is not the case, the command aborts because libraries incompatible with Python 3.11 cannot be installed in the official Docker images.

If a project is [encrypted](https://www.quantconnect.com/docs/v2/lean-cli/projects/encryption.md), you can only add a project library to it if the project library is unencrypted or is encrypted with the same key as the project. When you add a project library to a project, the name and path of the library is added to the [project configuration file](https://www.quantconnect.com/docs/v2/lean-cli/projects/configuration.md).

## Arguments

The `lean library add` command expects the following arguments:

| Argument | Description |
| --- | --- |
| `<project>` | The path to the project directory. |
| `<name>` | For third-party C# libraries, the name of the NuGet package to add. For third-party Python libraries, the name of the PyPI package to add. For project libraries, the path to the library in the `Library` directory of your [organization workspace](https://www.quantconnect.com/docs/v2/lean-cli/initialization/organization-workspaces.md). |

## Options

The `lean library add` command supports the following options:

| Option | Description |
| --- | --- |
| `--version <string>` | The version of the library to add (defaults to latest compatible version) |
| `--no-local` | Skip making changes to your local environment |
| `--verbose` | Enable debug logging |
| `--help` | Display the help text of the `lean library add` command and exit |
