# Ananconda

官方网站： [https://www.anaconda.com/”](https://www.anaconda.com/") <https://www.anaconda.com/> >

下载： [https://www.anaconda.com/download/”](https://www.anaconda.com/download/") <https://www.anaconda.com/download/> >

### Ananconda 是什么

Anaconda是Python的包管理器和环境管理器。

#### 已经有了python，为什么还需要 Ananconda?

1. Anaconda附带了一大批常用数据科学包，它附带了conda、Python和 150 多个科学包及其依赖项。因此你可以用Anaconda立即开始处理数据
2. 管理包。Anaconda 是在 conda（一个包管理器和环境管理器）上发展出来的。在数据分析中，你会用到很多第三方的包，而conda（包管理器）可以很好的帮助你在计算机上安装和管理这些包，包括安装、卸载和更新包
3. 管理环境。为什么需要管理环境呢？比如你在A项目中用到了Python2，而新的项目要求使用Python3，而同时安装两个Python版本可能会造成许多混乱和错误。这时候conda就可以帮助你为不同的项目建立不同的运行环境。还有很多项目使用的包版本不同，比如不同的pandas版本，不可能同时安装两个pandas版本。你要做的应该是在项目对应的环境中创建对应的pandas版本。这时候conda就可以帮你做到

### 安装Ananconda

下载地址： <https://www.anaconda.com/download/>

点击exe执行文件进行安装,并添加环境变量 `%Ananconda_HOME%/Scripts` 到Path下即可。

### 使用Ananconda管理包

**查询已经安装的包：**

```bash
conda list
```

**安装包：**

```bash
conda install matplotlib
```

**更新包：**

```bash
conda update matplotlib
```

**卸载包：**

```bash
conda remove matplotlib
```

**修改镜像：**

默认镜像地址是国外网络，下载速度过慢，可以将镜像改为清华大学：

```
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
```

### 使用Ananconda管理环境

conda可以为项目建立不同的运行环境，比如是使用python3还是python2。

**创建一个环境:**

```python
conda create –n python27 python=2.7 numpy
# -n 代表name，环境名称
# python=2.7 代表使用python版本2.7
# numpy是要安装在环境中的包名称
```

**进入环境（使用环境）：**

```
conda activate python27
```

**离开环境:**

```
deactivate
```

**共享环境:**

共享环境可以让其他人安装你代码中使用的所有包，并确保这些包的版本正确。你可以通过导出环境配置，并分享给其他人，从而达到环境共享的目的：

```
# 导出当前环境配置到yaml文件中
conda env export > environment.yaml
```

**导入环境：**

```
conda env update -f=/path/to/environment.yml
```

**列出环境：**

```
conda env list
```

**删除环境：**

```
conda env remove -n python27
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yangsx95.gitbook.io/notes/programming-language/python/build-tools/ananconda.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
