Anaconda虚拟环境管理、包管理和源管理

在这里插入图片描述

1.环境(Anacnoda)

1.Anaconda 的使用

  • 1.包管理

    • python --version

      • 查看python的版本信息
    • conda list

      • 查看安装的包
    • conda install xxx

      • 包的安装(pip install xxx)
    • conda remove xxx

      • 卸载包(pip uninstall xxx)
  • 2.环境管理

    • conda create --name xxx python2

      • 创建了python版本为2的环境
    • conda create --name xxx python3

      • 创建了python版本为3的环境
    • conda create --name xxx python3 anaconda

      • 创建了python版本为3的环境,并具有anaconda的所有包
    • conda env list

    • conda info --envs

    • [source该参数可选,当无法激活时] activate xxx

      • 激活环境
    • conda deactivate

      • 退出环境
    • conda remove --name xxx --all

      • 删除一个已有的环境
    • pip freeze > packages.txt
      packages.txt文件包含了当前环境中所有包及各自的版本的简单列表(即pip list 所列出的包列表)

2.Jupyter Notebook(注意工作空间切换)


在当前路径栏输入jupyter notebook,就在当前目录启动(骚操作)

3.添加源,改善软件安装速度(其中包括conda虚拟环境的创建和利用conda方式下载软件)

# 中科大源
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.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes  # 设置搜索时显示通道信息
# 清华源
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

注意:上述命令可以一次性复制,利用一次性复制中科大源到cmd,省时~

conda config --remove-key channels  # 换回默认源
conda config --remove channels https://xxx # 删除安装源
conda config --show <channels> # 显示当前源
或者使用 conda config --show-sources

利用pip安装软件提速

pip config set global.index-url 对应pip源链接
清华:https://pypi.tuna.tsinghua.edu.cn/simple
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/

输入以上命令后,在图示位置会创建一个文件
在这里插入图片描述

补充:
windows下详情:
开始菜单打开Anaconda Prompt(Anaconda3)
先执行,conda update conda,先把conda更新到最新版;
然后输入conda update anaconda,把anaconda更新的新版。
Anaconda已经更新完毕,启动anaconda-navigator,发现在配置的环境中,只有base这个环境更新到最新。
​​而自己常用的自定义配置的环境还是以前的版本。
通过前面介绍的命令进入到需要升级的配置环境中。
输入conda update --all
更新完毕后,你所使用的自定义配置环境也更新到最新版的Anaconda了。

Anaconda 创建虚拟环境报错

开启“梯子”试试!!!!结果很神奇!!!但是木有梯子就尴尬了
原因镜像源的问题,折腾了很多次,换源。。。。未成功。没梯子就是不行~
最近发现,可以通过图形化界面创建虚拟环境。
(1)ubuntu18.04环境下,输入下面的命令,启动Anaconda navigator,在这个里面图像化操作。

source ~/anaconda3/bin/activate root
anaconda-navigator

(2)windows10环境下
在这里插入图片描述
具体操作如下图,很是方便。
在这里插入图片描述

​​​​​​

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值