Ubuntu24.04安装Anaconda3+Pycharm-二、安装 Anaconda

1. Ubuntu 更换下载源

设置 root 账户:

sudo passwd root

进入 root 账户:

su root

使用gedit文本编辑器打开sources文件:

sudo gedit /etc/apt/sources.list.d/ubuntu.sources

将内容替换为:

Types: deb deb-src
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb deb-src
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb deb-src
URIs: http://mirrors.163.com/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb deb-src
URIs: https://mirrors.ustc.edu.cn/ubuntu/
Suites: noble noble-updates noble-backports noble-security noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb
URIs: http://cn.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

更新下载源:

sudo apt-get update

2. 安装 Anaconda

首先在镜像站下载Anaconda:清华大学开源软件镜像站
我下载的版本是:Anaconda3-2024.06-1-Linux-x86_64.sh
打开 sh 文件所在文件夹,右键用终端打开,安装:

bash Anaconda3-2024.06-1-Linux-x86_64.sh -b -p /xxx/xxx/anaconda3

然后会出现满屏的协议,一直回车或者下箭头,输入 yes 同意协议并继续安装,选择安装路径:

安裝之后默认没配置环境变量,选 no:

installation finished.
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:

conda config --set auto_activate_base false

You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>> no

You have chosen to not have conda modify your shell scripts at all.
To activate conda's base environment in your current shell session:

eval "$(/.../.../anaconda3/bin/conda shell.YOUR_SHELL_NAME hook)" 

To install conda's shell functions for easier access, first activate, then:

conda init

Thank you for installing Anaconda3!

3. 添加环境变量

sudo gedit ~/.bashrc  # 打开.bashrc文件
export PATH=~/anaconda3/bin:$PATH  # 在上一条命令打开的的.bashrc文件中最后一行新增环境变量,前提是安装anaconda3时安装在home/username/下,保存
source ~/.bashrc  # 使其生效
conda -V

在这里插入图片描述
注意这里是大写的 V。

4. 换源

先生成.condarc文件:

conda config

打开文件:

sudo gedit ~/.condarc

替换为以下内容并保存:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - 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/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

验证是否更改成功:

conda config --show-sources

在这里插入图片描述

上一篇:MySQL技巧之跨服务器数据查询:进阶篇-从A数据库复制到B数据库的表中


下一篇:快速利用c语言搭建一个链表(linklist)