Ubuntu apt-get和pip国内源更换

简介: Ubuntu apt-get和pip源更换更新数据源为国内,是为了加速安装包的增加速度。更换apt-get数据源输入:sudo -s切换为root超级管理员;执行命令:vim /etc/apt/sources.

Ubuntu apt-get和pip源更换

更新数据源为国内,是为了加速安装包的增加速度。

更换apt-get数据源

  1. 输入:sudo -s切换为root超级管理员;
  2. 执行命令:vim /etc/apt/sources.list;
  3. 使用命令:%d 清空所有内容;
  4. 清华数据源地址:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ 选择相应的版本复制内容,点击“i”键进入编辑文本模式,粘贴内容到vim编辑窗体,点击“ESC”键进入编辑模式,输入“:wq”保存离开;
  5. 更新源:sudo apt-get update
  6. 更新软件:sudo apt-get upgrade

pip3的安装与升级

安装pip3:sudo apt-get install python3-pip

升级pip3:sudo pip3 install --upgrade pip

查看pip版本:pip -V

pip源更换

  1. 根目录创建.pip文件:mkdir ~/.pip
  2. 创建文件pip.conf:vim .pip/pip.conf
  3. 点击“i”键,进入编辑模式,复制信息:
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    trusted-host = pypi.tuna.tsinghua.edu.cn
    这个更换的是清华的源,清华的源5分钟同步官网一次,建议使用。
    清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
    阿里云 http://mirrors.aliyun.com/pypi/simple/
    中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
    豆瓣(douban) http://pypi.douban.com/simple/
    中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

  4. 点击:“ESC”切换到命令行模式,输入“:wq”保存离开。

修改默认python版本号

我们也可以把Ubuntu的默认python版本号进行修改,步骤如下:

1、删除原有Python连接文件

sudo rm /usr/bin/python

2、切换成root账户,建立指向Python3的连接

切换root账户:sudo -s

建立执行Python3的连接

ln -s /usr/bin/python3.6 /usr/bin/python

以上操作就是完成默认Python版本号设置,使用:python -V查看默认版本号.

img_fa0be433d68c8212b2b0b3b1a564ccb1.png
如果本文对你有所帮助,请打赏——1元就足够感动我:)
支付宝打赏 微信打赏
联系邮箱:intdb@qq.com
我的GitHub: https://github.com/vipstone
关注公众号: img_9bde0f31ac4a0eca10b1bd7414b78faf.png


作者: 王磊
出处: http://vipstone.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,请标明出处。

相关文章
|
4月前
|
Ubuntu Linux 时序数据库
|
11月前
|
Ubuntu Python
百度搜索:蓝易云【如何在 Ubuntu 22.04 上安装 Python Pip?】
现在,你已经成功在Ubuntu 22.04上安装了Python Pip。你可以使用pip来安装Python包和库,并管理Python项目的依赖项。注意,使用 `pip3`命令来代替 `pip`命令,以确保使用的是Python 3的pip版本。
279 0
|
16天前
|
Ubuntu Java 应用服务中间件
如何通过 Apt-Get 在 Ubuntu 14.04 上安装 Apache Tomcat 7
如何通过 Apt-Get 在 Ubuntu 14.04 上安装 Apache Tomcat 7
44 0
|
13天前
|
Ubuntu 网络协议 数据安全/隐私保护
【Ubuntu】sudo apt-get update 无法解析域名(亲测有效)
在Ubuntu 18.04系统中,用户在执行sudo apt-get update时遇到“无法解析域名‘ip’”的错误。经分析,问题源于之前设置的网络代理配置未完全清除。解决方案是找到并重命名/etc/apt/apt.conf.d下的proxy.conf文件,使其不再生效。操作后,sudo apt-get update命令恢复正常,问题得到完美解决。
31 4
【Ubuntu】sudo apt-get update 无法解析域名(亲测有效)
|
2月前
|
Ubuntu Linux 文件存储
如何使用 Linux 构建自己的 NAS 系统?
【7月更文挑战第28天】
142 6
如何使用 Linux 构建自己的 NAS 系统?
|
29天前
|
Web App开发 缓存 Ubuntu
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
|
2月前
|
存储 缓存 Ubuntu
Ubuntu apt-get 命令大全
【7月更文挑战第12天】
71 6
Ubuntu apt-get 命令大全
|
24天前
|
Ubuntu Python
ubuntu build install python3.12 and config pip
ubuntu 编译安装 python ; 并配置 pip 仓库源
30 0
|
10月前
pip 更换源 国内源 阿里源
pip 更换源 国内源 阿里源
1174 0
|
2月前
|
缓存 Ubuntu Linux
下一篇
云函数