【linux】配置apt源

在Ubuntu上更改apt源并安装python和c++

  1. 更改apt源
    首先,备份现有的apt源代表:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

编辑APT源列表:

sudo nano /etc/apt/sources.list

将源列表内容更改为以下内容(以阿里云源为例):

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb 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 main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

保存并退出编辑器(按 Ctrl+O 保存,然后按 Ctrl+X 退出)。

更新APT包索引:

sudo apt update

更新应用:

sudo apt upgrade
  1. 安装python
    首先,检查默认python版本
python3 --version

如果需要特定版本的Python,可以使用以下命令安装:

sudo apt install python3.x

安装pip包管理工具:

sudo apt install python3-pip
pip3 --version
  1. 安装c++
sudo apt install g++
g++ --version
sudo apt install build-essential	# c++开发常用工具

可能安装g++时报错,可以按照提示执行

sudo apt autoremove
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值