关闭页面特效

Ubuntu安装anaconda和一些常用的conda命令

time stamp:2022-03-28

author: Weber

0|1实验环境


  • vmware ubuntu虚拟机

    $uname -a

    Linux weber-virtual-machine 5.11.0-40-generic #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

0|1实验步骤


1. 下载安装脚本

$wget -P /tmp https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh

如果下载速度过慢,可能是ubuntu没有换源,下面是给Ubuntu换源的步骤:

  1. 将原先的源进行备份

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  2. vim源文件并添加国内的源

    sudo vim/etc/apt/sources.list
    #配置内容(国内源): #阿里源 deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse #清华源 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse #中科大源 deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse #网易163源 deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
  3. 更新

    #更新源 sudo apt-get update #更新软件 sudo apt-get upgrade

2.验证脚本数据完整性

$sha256sum /tmp/Anaconda3-2021.11-Linux-x86_64.sh

输出类似于以下:

$fedf9e340039557f7b5e8a8a86affa9d299f5e9820144bd7b92ae9f7ee08ac60 /tmp/Anaconda3-2021.11-Linux-x86_64.sh

确保上面的命令打印出来的哈希值和https://docs.anaconda.com/anaconda/install/hashes/lin-3-64/ 页面对应版本的 Anaconda 哈希值一样。

fedf9e340039557f7b5e8a8a86affa9d299f5e9820144bd7b92ae9f7ee08ac60

3.运行脚本安装

$bash /tmp/Anaconda3-2021.11-Linux-x86_64.sh

输出:

Welcome to Anaconda3 2020.02 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>>

ENTER继续。往下滑动阅读协议,使用ENTER按键。一旦你看完协议,你将会被询问是否接受协议条款:

Do you approve the license terms? [yes|no]

输入yes接受协议,并且你会被提示选择安装路径:

Anaconda3 will now be installed into this location: /root/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below

默认的位置应该对大部分用户都可直接使用。按Enter确认位置。

安装过程将会花费一些时间,并且一旦完成,脚本将会问你是否想要运行conda init。输入yes

Installation finished. Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no]

这将会将命令行工具conda添加到系统的PATH环境变量中。

想要激活 Anaconda,你可以关闭并且重新打开你的 shell 或者在当前 shell 会话中输入下面的命令,来重新加载PATH环境变量:

source ~/.bashrc

想要验证安装过程,在你的终端输入conda

3.conda相关命令

创建环境

conda create --name your_env_name

输入y确认创建。

创建制定python版本的环境

conda create --name your_env_name python=2.7 conda create --name your_env_name python=3 conda create --name your_env_name python=3.5

创建包含某些包的环境

conda create --name your_env_name numpy scipy

创建指定python版本下包含某些包的环境

conda create --name your_env_name python=3.5 numpy scipy

列举当前所有环境

conda info --envs conda env list

进入某个环境

activate your_env_name

退出当前环境

deactivate

复制某个环境

conda create --name new_env_name --clone old_env_name

删除某个环境

conda remove --name your_env_name --all

__EOF__

作  者WeberBon
出  处https://www.cnblogs.com/Weber-security/p/16068074.html
关于博主:185猛男
版权声明:署名 - 非商业性使用 - 禁止演绎,协议普通文本 | 协议法律文本
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!

posted @   Weber·Bon  阅读(465)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
0
0
关注
跳至底部
点击右上角即可分享
微信分享提示