Python环境管理:Anaconda使用

Python环境管理:Anaconda使用

1、anaconda安装后需要更换国内源,以加快下载速度

1.1  命令行中更改

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

1.2  在配置文件中更改

在C:\Users\用户名\.condarc中进行更改,例如以下部分示例:

channels:
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/mro/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/pro/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/r/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mro/
  - defaults
show_channel_urls: true
ssl_verify: True

在此注明一下,上述更改的是conda命令的配置,如果需要更改pip命令的源地址,可用的方法是:

在文件夹C:\Users\用户名\pip中添加pip.ini文件,文件内容编辑如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

2、在Anaconda使用conda命令配置各种虚拟环境

例如,创建一个python27的环境,python版本为python2.7,可用如下方法:

conda create -n python27 python=2.7

这样就很轻松地创建了一个python2.7环境,类似还可以创建很多不同配置的环境以满足自己的需求。当要删除该环境时,执行如下命令:

conda remove -n python27 --all

切换环境用以下命令:

activate python27

# 退出使用
deactivate

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值