conda命令使用方式:
- 方式一:直接打开Anaconda prompt即可
- 方式二:打开anaconda,然后在environment中选择你用的环境,点击运行图标,选择Open Terminal
注意:
在线安装时,记得删掉后面的-c pytorch,因为它表示从pytorch官网进行下载,不从清华镜像源下
前面安装失败后,可以用下conda clean --all和conda update --all 然后在重新运行安装命令
常用命令
可以参考:https://blog.csdn.net/zhayushui/article/details/80433768
| 命令 | 功能 |
|---|---|
| conda -h | 查看帮助 |
| conda --version | 更多操作查看conda版本 |
| conda install django | 安装django包 |
| conda list | 查看已经安装的包 |
| conda update django | 更新包 |
| conda update --all | 更新所有包 |
| conda remove django | 删除包 |
| conda create –n name python=version | 创建环境 |
| conda activate name | 激活环境 |
| conda deactivate name | 退出当前环境 |
| conda remove –n name --all | 删除环境 |
| conda env list | 查看所有虚拟环境 |
| conda info --envs | 查看所有虚拟环境 |
| conda clean --all | 清理无用的包或安装包 |
| conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ | 添加下载源 |
| conda config --set show_channel_urls yes | 让下载时显示从哪儿下载的 |
| conda config --show channels | 展示所有的下载渠道 |
| conda install --offline pytorch-1.3.0-py3.6_cuda9.2.148_cudnn7.6.3_0.tar.bz2 | conda进行离线安装 |
| conda config --show | 显示出所有conda的config信息 |
| conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ | 移除之前conda config --show channels显示的清华源 |
| conda config --set always_yes false | 这里的意思是安装确认中,不默认yes,而是由我来决定 |
conda create -n pytorch python=3.6 #conda 是指调用 conda 包,create 是创建的意思,-n 是指后面的名字是屋子的名字, pytorch是屋子的名字(可以更改成自己喜欢的),python=3.6 是指创建的屋子,是 python3.6 版本。 conda info --envs #看到 conda 环境中,有新建的 pytorch 环境,右边的 * 号表示,当前你处于哪个环境。 conda activate pytorch #进入 pytorch 环境2. 配置镜像源
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 --set show_channel_urls yes conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda config --show channels3. 离线安装
conda install --offline pytorch-1.3.0-py3.6_cuda9.2.148_cudnn7.6.3_0.tar.bz2 #注意先用cd切换至文件所在目录 conda install --offline torchvision-0.4.1-py36_cu92.tar.bz24. 移除原来的源,然后添加新源,并安装包
conda config --show #显示出所有conda的config信息 conda config --show channels #显示channels信息 conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ #移除之前conda config --show channels显示的清华源 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 --set show_channel_urls yes#从channel中安装包时显示channel的url conda config --set always_yes false #这里的意思是安装确认中,不默认yes,而是由我来决定 conda install <包名> 安装指定包 conda remove <包名> 移除指定包 conda update <包名> 更新指定包4. 中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/3. pip的一些操作 1. pip指定从哪个源安装(临时使用):
# 可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple 如: pip install numpy -i https://mirrors.aliyun.com/pypi/simple/2. pip配置镜像源(永久有效)
1.Windows系统 windows下,直接在user目录中创建一个pip目录,如:C:Usersxxpip,新建文件pip.ini,内容如下: [global] index-url = https://mirrors.aliyun.com/pypi/simple/ 2.Linux系统 mkdir ~/.pip cd ~/.pip vim pip.conf 内容和上面的一样 [global] index-url = https://mirrors.aliyun.com/pypi/simple/ 3.下载测试国内常用镜像源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/



