CentOS7 安装Python3.6.8

1. 安装依赖环境

yum -y groupinstall "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

2、下载Python3.6.8

新建个/usr/local/python3文件夹

mkdir /usr/local/python3

  
在python3文件夹下下载安装包

(/usr/local/python3 )

wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz

解压文件

tar -xvf Python-3.6.8.tar.xz

3、安装Python3

创建安装文件的路径

mkdir /usr/local/python3

4、编译(在解压的文件夹下 /usr/local/python3/python3.6.8)

./configure --prefix=/usr/local/python3

5、安装(在解压的文件夹下 /usr/local/python3/python3.6.8)

make
make install  # 先make再make install

6、创建新版本的软链接

修改旧版本

mv /usr/bin/python /usr/bin/python_bakmv /usr/bin/pip /usr/bin/pip_bak

创建新的软连接  

ln -s /usr/local/python3/bin/python3 /usr/bin/pythonln -s /usr/local/python3/bin/pip3 /usr/bin/pip

检查python的版本

python -V

7、配置成功后,pip3用不了,需要进一步配置

将/usr/local/python3/bin加入PATH

vim ~/.bash_profile

修改后如下: 
.bash_profile

 #Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

export PATH

复制代码 
保存退出后,执行以下命令,让上一步修改成功

source ~/.bash_profile 
完成!

不过,由于yum是py2写的,所以更换完python路径后,yum可能会出现错误 
所以要修改配置文件

vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down

把第一行python改为python2

原文地址:https://www.cnblogs.com/klsw/p/11106166.html

时间: 2024-10-03 02:29:29

CentOS7 安装Python3.6.8的相关文章

centos7安装python3和Django后,ModuleNotFoundError: No module named '_sqlite3'

1.准备安装环境 yum groupinstall 'Development Tools' yum install zlib-devel bzip2-devel openssl-devel ncurses-devel 2.安装python3 去官网下载编译安装包或者直接执行以下命令下载 wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz 解压 tar -xvJf  Python-3.6.2.tar.xz 切换进入 cd

Centos7 安装Python3.6.5 及 安装ipython 6.1.0

一.centos7 安装 Python3.6.5教程 1.在安装Python之前,需要先安装一些后面遇到的依赖问题(如果有依赖问题,按照提示安装): yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel     yum install xz gcc zlib 

Centos7安装Python3的方法

由于centos7原本就安装了Python2,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到. [[email protected]_105_217_centos Python-3.6.2]# python Python 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2 Type "help", "copyright"

CentOS7安装python3.6

下载包 去官网下载最新的python安装包 官网地址: https://www.python.org/downloads/ 安装python3.6可能使用的依赖 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel yum install -y readline-devel.x86_64 (一定要安装这个包,不然升级完成后会发现删除退格键用不了) 时间同步 ntpdate

Centos7安装Python3详细步骤

这一篇是在一个大神基础上改动的 安装python3.6可能使用相关软件 这里如果不安python3可能也可以正常安装,但是当用的时候就会出问题,所以都安装一下 # yum groupinstall 'Development Tools' # yum install -y ncurses-libs zlib-devel mysql-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel g

centos7安装python3.7

本想对照自己之前的记录来安装python3,结果使用多年的nyfedit突然罢工,连数据也损坏了,多年的积累就这样回归虚无... 再次记录centos7.5安装python3过程 下载安装包 官网 cd /usr/local/src wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz 安装 # 依赖 yum install -y zlib-devel bzip2-devel readline-devel openssl-de

centos7 安装python3.6 及模块安装演示

目录: 下载python3.6 安装python3.6的依赖 编译安装 更改链接 更改yum脚本的python依赖 修改gnome-weaktool配置文件 修改urlgrabber配置文件 1.下载python3.6 # wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz 2.安装python3.6的依赖 # yum install openssl-devel bzip2-devel expat-devel gdbm-de

centos7安装python3 以及tab补全功能

1.安装python3 1.1下载python源码包 网址:https://www.python.org/downloads/release/python-362/ 下载地址:https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz 1.1.1安装python前的库环境,非常重要 yum install gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-d

centos7 安装python3.6 脚本

shell 脚本自动安装python3 # /bin/bash cd /opt yum groupinstall "Development tools" -y yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel wget https://www.p

Centos7安装python3.7.1并与python2共存

转自:http://www.cnblogs.com/JahanGu/p/7452527.html参考:https://www.jb51.net/article/104326.htm 1. 备份原来的python版本.查看是否已经安装Python:[[email protected] ~]$ python -VPython 2.7.5[[email protected] ~]$ 查看一下Python可执行文件的位置:[[email protected] ~]$ which python/usr/b