Python3安装
Posted zenosblog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python3安装相关的知识,希望对你有一定的参考价值。
CentOS 7 默认安装了python2.7.5 因为一些命令要用它比如yum 它使用的是python2.7.5
1.首先安装依赖包
a. yum -y groupinstall “Development tools”
b. 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.下载安装依赖包
a. wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
b. tar -xvJf Python-3.7.0.tar.xz
c. cd Python-3.7.0
d. ./configure –prefix=/usr/local/python3
e. make && make install
3.安装完毕,/usr/local/目录下就会有python3了
添加软链到执行目录下/usr/bin
- ln -s /usr/local/python3/bin/python3 /usr/bin/python
【遗留问题】
1.【这一步遇到ModuleNotFoundError: No module named ‘_ctypes’ make: *** [install] Error 1】
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 libffi-devel -y
2.【yum需要python2版本,所以我们还要修改yum的配置】
- vim /usr/bin/yum 把 #! /usr/bin/python修改为 #! /usr/bin/python2
2. vim /usr/libexec/urlgrabber-ext-down 把#! /usr/bin/python 修改为 #! /usr/bin/python2
以上是关于Python3安装的主要内容,如果未能解决你的问题,请参考以下文章