栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

anaconda使用笔记(包括pip命令)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

anaconda使用笔记(包括pip命令)

anaconda使用笔记(包括pip命令) 1. conda命令

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.bz2conda进行离线安装
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,而是由我来决定
2. conda常用操作 1. 环境管理:
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 channels
3. 离线安装
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.bz2
4. 移除原来的源,然后添加新源,并安装包
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/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/286822.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号