Linux下的Ubuntu系统下载安装python3.9.0
Posted m0_59268754
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下的Ubuntu系统下载安装python3.9.0相关的知识,希望对你有一定的参考价值。
在安装python3.9.0之前,首先要进行换源,这样才能防止下载过慢的情况。
我这里换的是阿里云的镜像源,在终端输入一下命令。
其他镜像源可以查看:https://www.myfreax.com/ubuntu-22-04geng-gai-jing-xiang-ruan-jian-yuan/
sudo bash -c "cat << EOF > /etc/apt/sources.list && apt update
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF"
开始之前要安装依赖
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
1.下载python3.9.0
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
2.对下载后的python3.9.0进行解压
tar -zxvf Python-3.9.0.tgz
3.解压后进入Python-3.9.0目录
cd Python3.9.0/
4.开始安装
./configure --enable-optimizations
接着执行以下代码
make
sudo make install
5.设置软链接
rm python
which python3
找到的路径建立新的链接
sudo ln -s /usr/local/bin/python3 /usr/bin/python
6.设置python的环境变量
vim ~/.bashrc
在bashrc里面添加一下代码
allias python='/usr/local/bin/python3'
然后让变量生效
source ~/.bashrc
最后直接输入python就可以了
以上是关于Linux下的Ubuntu系统下载安装python3.9.0的主要内容,如果未能解决你的问题,请参考以下文章
python入门开发:ubuntu下搭建python开发环境(vscode)
Ubuntu Linux系统 共存了python2和3。下载安装了matplotlib