> For the complete documentation index, see [llms.txt](https://yangsx95.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yangsx95.gitbook.io/notes/programming-language/python/build-tools/requirements.txt.md).

# requirements.txt

## pip

### 导出结果含有路径

```console
pip freezen > requirements.txt
```

### 导出结果不含有路径

```console
pip list --format=freeze >requirement.txt
```

## Conda

### 导出requirements.txt

```console
conda list -e > requirements.txt
```

### 导入requirements.txt

```console
conda install --yes --file requirements.txt
```

### 导出yaml

```console
conda env export > freeze.yml
```

### 导入yaml

```yaml
conda env create -f freeze.yml
```

## pipreqs

使用**pipreqs**，这个工具的好处是可以通过对项目目录的扫描，发现使用了哪些库，生成依赖清单。

### 安装pipreqs(默认没有安装)

```console
pip install pipreqs
```

### 使用pipreqs导出 requirements.txt

```console
pipreqs ./
# 如果报错可能是编码问题
pipreqs ./ --encoding=utf-8
```
