当前位置:首页 » 《随便一记》 » 正文

Linux下的Ubuntu系统下载安装python3.9.0

1 人参与  2023年04月02日 16:57  分类 : 《随便一记》  评论

点击全文阅读


在安装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就可以了


点击全文阅读


本文链接:http://zhangshiyu.com/post/58056.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1