一、引言
重装系统已经过去一段时间了,现在安装一下 Anaconda 和 Pycharm。
参考连接:
- Ubuntu中安装Anaconda3和Pycharm 及其环境搭建
- Ubuntu18.04安装Pycharm教程
- ubuntu系统安装Anaconda及Pycharm
- 在移动硬盘上搭建Ubuntu24.04深度学习环境(Anaconda + CUDA + Pytorch)
二、安装 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.gpgTypes: 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.gpgTypes: 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.gpgTypes: 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.gpgTypes: 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.gpgTypes: 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 falseYou can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>> noYou 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 initThank 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/cloudmsys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudbioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmenpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudsimpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
验证是否更改成功:
conda config --show-sources
三、安装 Pycharm
1.下载Pycharm
官网链接:下载 PyCharm:JetBrains 出品的用于数据科学和 Web 开发的 Python IDE
选择其他版本,下载社区版。解压到本地后,打开文件夹,cd 到 bin 文件夹下,用终端打开,执行:
bash pycharm.sh
安装成功。