centos6下安装python3环境

Posted yugengde

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6下安装python3环境相关的知识,希望对你有一定的参考价值。

1. 下载python3.6

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

 

2. 解压缩

 tar -zxvf Python-3.6.4.tgz

mkdir -p /usr/local/python3

 

3. 安装依赖

yum install openssl openssl-devel

yum install zlib zlib-devel

 

4. 

vim Modules/Setup

#Socket module helper for socket(2)
_socket socketmodule.c timemodule.c

#Socket module helper for SSL support; you must comment out the other
#socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl -L$(SSL)/lib -lssl -lcrypto

 

5. 配置

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

 

6. 安装

make && make install 

 

7. 设置环境变量

cp /root/.bashrc /root/.bashrc.bak

echo ‘export PATH="$PATH:/usr/local/python/bin/">> /root/.bashrc

 

8. 创建虚拟环境

virtualenv -p /usr/local/python3/bin/python3.6 py36env  //会在当前的路径下生成一个py36env的文件夹

 

9. 激活虚拟环境

source /home/work/py36env/bin/activate

 

10. 退出虚拟环境

deactivate

 


以上是关于centos6下安装python3环境的主要内容,如果未能解决你的问题,请参考以下文章

CentOS6.8安装Python3.6.3

centos6.4下安装python3.6.1

centos6安装Python3环境

centos6.5 安装python3.8

Centos6.5中实现python2与python3的并存

Centos6.9下创建python3虚拟环境