---
# System prepended metadata

title: Anaconda & Pip Note
tags: [python, ' pip', ' anaconda']

---

---
title: Anaconda & Pip Note
tags: python, anaconda, pip
---
[TOC]

[Official Document](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)

# Conda
- conda list
    - 可以查看已經安裝哪些模組
- conda search `module`
    - 查詢module
- conda update `module`
    - 更新模組
```bash=
conda update -n base -c defaults conda  # 更新conda
```
- conda install `module`
    - 下載模組
```python=
conda install tensorflow==2.2.0  # 指定版本
```
- conda uninstall `module`
    - 刪除模組
- conda -V
    - 查看版本

# 虛擬環境相關
- conda env list
    - 查看目前系統已經安裝幾個虛擬環境
- conda create -n env_name [python=3.6] [anaconda]
    - `-n`: 後接上虛擬環境名稱
    - `python=`: python 版本
    - `anaconda`: 可以安裝預設套件
- conda activate env_name
    - 啟動虛擬環境
- conda deactivate
    - 離開虛擬環境
- conda remvoe -n env_name --all
    - 刪除環境
- conda remvoe -n env_name `module`
    - 刪除`module`

```bash=
conda create -n pyenv
conda install pip
pip install some package
```

---
# Pip
- `pip unsintall <module>`
- `pip install <module>`
    - `pip install tensorflow==2.2.0`
    - 更新 `<module>`
        - `pip install -U pip`
        - `pip install -U <module>==<version>`
    - `pip install -r requirements.txt`
        - `requirements.txt` 列出需要安裝的套件
- `pip list [--outdated]`
    - 列出所有套件
    - `--outdated`: 列出所有須更新的套件
- `pip show [--file] <module>`
    - 列出`module`資訊
    - `--file`: 查看該 `<module>` 路徑
- `pip search <module>`
    - 查詢該 `<module>` 資訊
- `pip -V`
    - 查詢 pip 版本
- `pip freeze > requirements.txt`
    - 抓出當前所有套件的版本

---
# Virutual Enviroment

`python -m venv <venv_name> --python=python3.6`
In Linux or macOS
`source venv_name/bin/activate`
In Windows
`venv_name/Scripts/actiavte`

