python3环境搭建

2020-01-20 11:11:14 浏览数 (1)

安装依赖环境

代码语言:javascript复制
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  

下载python3

centos系统下安装

代码语言:javascript复制
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

安装python3

代码语言:javascript复制
//移动到一个合适的目录方便查找
mkdir -p /usr/local/python3
mv Python-3.7.1.tgz /usr/local/python3

//解压包
tar -zxvf Python-3.7.1.tgz

//指定编译位置,就是当前位置
./configure --prefix=/usr/local/python3

//安装
make && make install

//建立软链接
ln -s  /usr/local/python3/bin/python3 /usr/bin/python3


//.bash_profile添加查找路径
PATH=$PATH:$HOME/bin:/usr/local/python3/bin

//更新
source ~/.bash_profile

报错处理

代码语言:javascript复制
1. ModuleNotFoundError: No module named '_ctypes

 安装 yum install -y gcc
 
2. configure: error: no acceptable C compiler found in $PATH

 安装  yum install -y libffi-devel 
 
3. python链接已存在

 改名 mv /usr/bin/python  /usr/bin/python.bak

0 人点赞