Anaconda 中的一些常用命令和镜像源

镜像源

Windows下使用:

中科大镜像源:

conda config --remove-key channels
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple

清华大学镜像来源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes

恢复默认源:

conda config --remove-key channels

anaconda中的命令行

新手在接触anaconda时往往不知道如何通过命令行执行一些常用的操作。
下面盘点一些容易记住且在cmd命令行窗口中常用的命令

1.查看anaconda中的所有环境

conda info envs

将显示您拥有的环境和路径

2.创建环境

conda create -n your_env python==3.x

your_env :你想要创建的环境的名称
Python==3.x用于指定新环境下,你需要安装哪个版本的python,目前基本上是3.6以上了

3.管理环境

(1)创建新环境

激活并进入your_env这个环境.

conda activate your_env

若单击Anaconda Prompt进入命令行窗口,默认环境是base,当你想要进入你新创建的环境时可省略conda

(2)从新环境中退出

当你想要从your_env这个环境退回到root环境时,输入以下命令

conda deactivate your_env
(3)删除环境

删除环境your_env以及环境下所安装的第三方包时,输入以下命令

conda remove -n your_env -all

3.环境包管理

(1)安装某个包

如numpy

conda install numpy

要么

pip install numpy

当需要安装一些常用的包时,有一种偷懒的方式

conda install anaconda 

这样可以安装anaconda平台上自带的一些包

(2)搜索某个包
conda search numpy 

用于搜索anaconda这个平台上的numpy包

(3)查询已有包
conda list

可以查询到该环境中已经安装的包的信息(版本号和所基于的python版本)

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2022年4月4日 下午6:27
下一篇 2022年4月6日 下午6:15

相关推荐