ubuntu 安装 anaconda

ubuntu 安装 anaconda

  1. 下载

    bash 复制代码
    wget https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh
  2. 安装

    bash 复制代码
    bash Anaconda3-2023.09-0-Linux-x86_64.sh

    2.1 回车继续

    2.2 许可协议

    输入 q 退出阅读许可协议

    2.3 输入 yes 接受 许可协议

    2.4 设置 anaconda 安装位置 如不需要更改直接回车

    2.5 安装完成是否激活 conda 环境

    如果选择激活 conda 环境 输入 yes 回车即可,后面是步骤不需要执行

    如果选择不激活 conda 环境,按需激活相应的虚拟环境 输入 no

  3. 查看当前默认 shell

    bash 复制代码
    echo $SHELL
  4. 确认 shell 类型

    bash 复制代码
    eval "$(/home/lhz/anaconda3/bin/conda shell.bash hook)"
  5. 激活 conda

    bash 复制代码
    conda init
  6. 验证

    bash 复制代码
    conda env list
  7. 启动时不进入 conda 的 base 环境,按需激活相应的虚拟环境

    bash 复制代码
    vim ~/.bashrc

    最后一行追加以下内容:
    不推荐

    bash 复制代码
    # 不推荐
    conda config --set auto_activate_base false

    推荐

    bash 复制代码
    # 推荐
    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/home/lhz/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
        eval "$__conda_setup"
    else
        if [ -f "/home/lhz/anaconda3/etc/profile.d/conda.sh" ]; then
            . "/home/lhz/anaconda3/etc/profile.d/conda.sh"
        else
            export PATH="/home/lhz/anaconda3/bin:$PATH"
        fi
    fi
    unset __conda_setup
    # <<< conda initialize <<<

    使环境变量生效

    bash 复制代码
    source ~/.bashrc
  8. 修改国内镜像源

    8.1 查看当前镜像源

    bash 复制代码
    conda config --show channels

    8.2 添加国内清华镜像源

    bash 复制代码
    conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
    conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

    8.3 设置检索路径

    bash 复制代码
    conda config --set show_channel_urls yes

    8.4 再次查看当前镜像源

    bash 复制代码
    conda config --show channels

    8.5 移除默认镜像源

    bash 复制代码
    conda config --remove channels defaults

    8.6 镜像源配置文件

    镜像源配置文件保存在当前用户主目录下的 .condarc 文件中

    我的配置文件路径 /home/lhz/.condarc

    bash 复制代码
    auto_activate_base: false
    channels:
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    show_channel_urls: true
  9. 升级 conda

    bash 复制代码
    conda update -y conda
相关推荐
禹凕12 小时前
Python编程——进阶知识(面向对象编程OOP)
开发语言·python
code monkey.12 小时前
【Linux之旅】Linux 进程间通信(IPC)全解析:从管道到共享内存,吃透进程协作核心
linux·c++·ipc
匆匆那年96712 小时前
llamafactory推理消除模型的随机性
linux·服务器·学习·ubuntu
一晌小贪欢12 小时前
深入理解 Python HTTP 请求:从基础到高级实战指南
开发语言·网络·python·网络协议·http
七牛云行业应用12 小时前
1M上下文腐烂?实测Opus 4.6 vs GPT-5.3及MoA降本架构源码
人工智能·python·llm·架构设计·gpt-5·claude-opus
好好学习天天向上~~12 小时前
5_Linux学习总结_vim
linux·学习·vim
馨谙12 小时前
Ansible模块化Playbook管理:静态导入与动态包含详解
运维·ansible
聆风吟º17 小时前
CANN开源项目深度实践:基于amct-toolkit实现自动化模型量化与精度保障策略
运维·开源·自动化·cann
Java后端的Ai之路17 小时前
【Python 教程15】-Python和Web
python
Coder个人博客18 小时前
Linux6.19-ARM64 mm mmu子模块深入分析
大数据·linux·车载系统·系统架构·系统安全·鸿蒙系统