Ubuntu安装Python

简介: Ubuntu安装Python

原文链接

Ubuntu安装Python的方式与其他Linux系统有所不同,在这里介绍一下。

配置环境

切换的国内源:

sudo gedit /etc/apt/sources.list

将原有的源注释掉,添加如下内容:

#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

更新apt-get

sudo apt-get update

安装build-essential

sudo apt-get install build-essential

安装Python

安装Python3.8:

sudo apt-get install python3.8
sudo apt install python3-pip

查看是否成功:

查看Python是否安装成功:

python3 --version

输出版本号Python 3.8.5即表示安装成功。

Ubuntu更换源

临时更换

使用阿里源:

pip install *** -i https://mirrors.aliyun.com/pypi/simple/

永久更换

新建.pip隐藏文件夹:

cd ~ 
mkdir .pip

新建pip.conf文件:

cd .pip
touch pip.conf

用vim编辑pip.conf文件

vim pip.conf

内容如下:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple
[install]
trusted-host=mirrors.aliyun.com

 
 

学习更多编程知识,请关注我的公众号:

代码的路

 
 

相关文章
|
1天前
|
开发者 Python
确保你的Python环境中已经安装了`python-docx`模块。如果还没有安装,可以通过pip来安装:
确保你的Python环境中已经安装了`python-docx`模块。如果还没有安装,可以通过pip来安装:
8 1
|
6天前
|
自然语言处理 安全 Shell
【Python】已解决:Python pip正确安装pyhanlp库步骤
【Python】已解决:Python pip正确安装pyhanlp库步骤
12 2
|
6天前
|
开发者 Python
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
13 0
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
|
1天前
|
Python
确保你已经安装了`python-barcode`库。如果没有,可以通过pip来安装:
确保你已经安装了`python-barcode`库。如果没有,可以通过pip来安装:
6 0
|
4天前
|
Ubuntu C语言
【Ubuntu20.04】安装gcc11 g++11, Ubuntu18.04
以上就是在Ubuntu 20.04和Ubuntu 18.04上安装gcc11和g++11的步骤。
7 0
|
6天前
|
IDE 开发工具 Python
【Python】已解决:pip安装第三方模块(库)与PyCharm中不同步的问题(PyCharm添加本地python解释器)
【Python】已解决:pip安装第三方模块(库)与PyCharm中不同步的问题(PyCharm添加本地python解释器)
23 0
|
6天前
|
安全 网络安全 Python
【Python】已解决:(pip安装库报错)ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访
【Python】已解决:(pip安装库报错)ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访
13 0
|
6天前
|
Python
【Python】不小心卸载pip后(手动安装pip的两种方式)
【Python】不小心卸载pip后(手动安装pip的两种方式)
8 0
|
6天前
|
NoSQL Shell MongoDB
【Python】已解决:(MongoDB安装报错)‘mongo’ 不是内部或外部命令,也不是可运行的程序
【Python】已解决:(MongoDB安装报错)‘mongo’ 不是内部或外部命令,也不是可运行的程序
13 0
|
6天前
|
Ubuntu 编译器 C语言
【Python】已解决:(paddleocr库安装报错) error: subprocess-exited-with-error × Running setup.py install for pyth
【Python】已解决:(paddleocr库安装报错) error: subprocess-exited-with-error × Running setup.py install for pyth
19 0