Blame
|
1 | # anaconda 使用 |
||||||
| 2 | ||||||||
| 3 | 视频教程:[Get Started with Anaconda](https://freelearning.anaconda.cloud/get-started-with-anaconda) |
|||||||
| 4 | ||||||||
| 5 | ```sh |
|||||||
| 6 | conda --version |
|||||||
| 7 | ``` |
|||||||
| 8 | ||||||||
| 9 | 列出环境 |
|||||||
| 10 | ||||||||
| 11 | ```sh |
|||||||
| 12 | conda env list |
|||||||
| 13 | ``` |
|||||||
| 14 | ||||||||
| 15 | 查看conda已安装的依赖 |
|||||||
| 16 | ||||||||
| 17 | ```sh |
|||||||
| 18 | conda list |
|||||||
| 19 | ``` |
|||||||
| 20 | ||||||||
| 21 | # Conda Workflow |
|||||||
| 22 | ||||||||
| 23 | 1. Create an environment |
|||||||
| 24 | 2. Activate an environment |
|||||||
| 25 | 3. Install packages |
|||||||
| 26 | 4. Launch JupyterLab |
|||||||
| 27 | 5. Deactivate an environment |
|||||||
| 28 | ||||||||
| 29 | You should always create a new environment for your work. Never work in (base)! |
|||||||
| 30 | ||||||||
| 31 | 创建环境 |
|||||||
| 32 | ||||||||
| 33 | ```sh |
|||||||
| 34 | conda create --name example |
|||||||
| 35 | ``` |
|||||||
| 36 | ||||||||
| 37 | 激活环境 |
|||||||
| 38 | ||||||||
| 39 | ```sh |
|||||||
| 40 | conda activate example |
|||||||
| 41 | ``` |
|||||||
| 42 | ||||||||
| 43 | 使用 conda 安装依赖 |
|||||||
| 44 | ||||||||
| 45 | ```sh |
|||||||
| 46 | conda install jupyterlab dask pandas hvplot |
|||||||
| 47 | ``` |
|||||||
| 48 | ||||||||
| 49 | 安装 conda-forge |
|||||||
| 50 | ||||||||
| 51 | ```sh |
|||||||
| 52 | conda install -c conda-forge condastats |
|||||||
| 53 | ``` |
|||||||
| 54 | ||||||||
| 55 | 开启 jupyter-lab |
|||||||
| 56 | ||||||||
| 57 | ```sh |
|||||||
| 58 | jupyter-lab |
|||||||
| 59 | ``` |
|||||||
| 60 | ||||||||
| 61 | ```sh |
|||||||
| 62 | jupyter notebook |
|||||||
| 63 | ``` |
|||||||
| 64 | ||||||||
| 65 | ```sh |
|||||||
| 66 | jupyter lab |
|||||||
| 67 | ``` |
|||||||
| 68 | ||||||||
| 69 | 退出当前环境 |
|||||||
| 70 | ||||||||
| 71 | ```sh |
|||||||
| 72 | conda deactivate |
|||||||
| 73 | ``` |
|||||||
| 74 | ||||||||
| 75 | ## 其他 |
|||||||
| 76 | ||||||||
| 77 | 创建环境时,指定 python 版本 |
|||||||
| 78 | ||||||||
| 79 | ```sh |
|||||||
| 80 | conda create --name example39 python=3.9 |
|||||||
| 81 | ``` |
|||||||
| 82 | ||||||||
| 83 | 导出环境 |
|||||||
| 84 | ||||||||
| 85 | ```sh |
|||||||
| 86 | conda env export >defaultpy39env.yml |
|||||||
| 87 | ``` |
|||||||