Python3.9安装

步骤:

1.查看是否安装
2.确定安装路径下,这里定为/opt/python3(Linux软件安装通常安装在/usr/local目录下)
3.下载安装python对应的依赖(能避免很多问题,暂不清除缘由)
4.下载安装包
5.解压到对应路径并执行安装
6.添加软链接(类似于window电脑的快捷方式)

1.查看是否安装
which python 
2.确定安装目录

此处安装在:/opt/python3目录

3安装依赖:
yum install   -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
4下载安装包
cd /opt/software/   
wget  https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgz
5.解压压缩包并安装
1. 解压  
    tar  -xvf Python-3.9.13.tgz   
2. 进入解压的文件夹  
    cd   Python-3.9.13  
3. 执行初始化,配置安装路径  
    ./configure prefix=/opt/python3  
4. 执行编译安装  
    make   
    make install

5. 添加环境变量:  
    vim  /etc/profile  
    export PATH=/opt/python3/bin:$PATH  
  
    source /etc/profile  
6. 添加软连接
[root@ec-new-app opt]# ln -s /opt/python3/bin/python3.9 /usr/bin/python3
[root@ec-new-app opt]# ln -s /opt/python3/bin/pip3.9 /usr/bin/pip3
[root@ec-new-app opt]# python3  -V
Python 3.9.13
[root@ec-new-app opt]# pip3  -V
pip 22.0.4 from /opt/python3/lib/python3.9/site-packages/pip (python 3.9)

能返回版本号就说明已经安装完成了!!

# 查看软连接指向
[root@ec-new-app opt]# ll /usr/bin/ |grep python
-rwxr-xr-x.   1 root root       11232 Aug 13  2019 abrt-action-analyze-python
lrwxrwxrwx    1 root root          23 May 23 17:09 pip3 -> /opt/python3/bin/pip3.9
lrwxrwxrwx.   1 root root           7 Jun 10  2022 python -> python2
lrwxrwxrwx.   1 root root           9 Jun 10  2022 python2 -> python2.7
-rwxr-xr-x.   1 root root        7216 Aug  7  2019 python2.7
lrwxrwxrwx    1 root root          26 May 23 17:07 python3 -> /opt/python3/bin/python3.9

[root@ec-new-app opt]# ll /usr/bin/ |grep pip
-rwxr-xr-x.   1 root root        2291 Jul 31  2015 lesspipe.sh
lrwxrwxrwx    1 root root          23 May 23 17:09 pip3 -> /opt/python3/bin/pip3.9
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐