码迷,mamicode.com
首页 > 编程语言 > 详细

centos7中安装python3

时间:2019-09-06 18:56:50      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:mkdir   处理   mod   python3   readline   编译安装   under   pca   nss   

1.安装相应的编译工具

在root用户下(不要用普通用户,麻烦),全部复制粘贴过去,一次性安装即可.

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
yum install libffi-devel -y
yum install zlib* -y

2.下载安装包

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

3.解压

tar -xvJf  Python-3.7.2.tar.xz

4.创建编译安装目录

mkdir /usr/local/python3 

5.安装

cd Python-3.7.2
./configure --prefix=/usr/local/python3
make && make install

6.创建软链接

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

7.验证是否成功

python3 -V
pip3 -V

8.报错处理

错误1.

zipimport.ZipImportError: can't decompress data; zlib not available Makefile:1099: recipe for target 'install' failed make: *** [install] Error 1

需要安装依赖

yum -y install zlib1g-dev

错误2.

ModuleNotFoundError: No module named '_ctypes'

需要安装依赖

yum -y install libffi-devel 

centos7中安装python3

标签:mkdir   处理   mod   python3   readline   编译安装   under   pca   nss   

原文地址:https://www.cnblogs.com/xiujin/p/11477419.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!