Linux安装python3
Linux自带python2环境,以下是python3的安装步骤
一、python3安装包下载地址:https://www.python.org/downloads/release/python-380/
也可以使用wget命令下载:
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
报错未找到wget需要使用以下命令安装
yum -y install wget
二、上传到linux服务器
1. cd到home目录下新建一个python文件夹(安装目录)
[root@localhost ~]# cd /home
[root@localhost home]# mkdir python
2. 将安装包用xftp上传到python目录下解压
[root@localhost python]# tar -zxvf Python-3.6.5.tgz
解压之后生成Python-3.8.0文件夹
[root@localhost python]# cd Python-3.8.0
三、安装依赖包:
yum update -y
yum groupinstall -y 'Development Tools'
yum install -y gcc openssl-devel bzip2-devel libffi-devel
四、配置安装路径
[root@localhost python]# cd Python-3.8.0
[root@localhost Python-3.8.0]#
./configure --prefix=/usr/local/python3 --with-ssl
五、编译并安装命令:
[root@localhost Python-3.8.0]# make & make install
时间较长,需要耐心等待
六、建立软链接
[root@localhost Python-3.8.0]#
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@localhost Python-3.8.0]#
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
七、增加环境变量
修改配置文件/etc/profile,
[root@localhost Python-3.8.0]# vim /etc/profile
增加以下内容:
PATH=$PATH:$HOME/bin:
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
执行语句source /etc/profile使环境变量配置立即生效
[root@localhost Python-3.8.0]# source /etc/profile
八、测试安装是否成功
[root@localhost ~]# python3
Python 3.8.0 (default, Mar 17 2023, 11:25:00)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
标签:Python,python3,Centos7,python,3.8,Linux,root,localhost From: https://www.cnblogs.com/tiannan-haibei/p/17225396.htmlctrl d 退出python3
九、测试pip是否能正常使用
参考https://www.cnblogs.com/wfw001-2018/p/12679881.html