centos7.3安装python3.6

1.下载python3.6源码

shell>wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

 

2.解压文件以及安装

shell>tar -xvf Python-3.6.1.tgz   (解压到指定目录需要添加-C参数)

shell>cd Python-3.6.1

shell>./configure --prefix=/usr/python3.6.1

shell>make

shell>make install

 

3.默认使用python3.6.1

shell>cd /usr/bin/

shell>mv python python.backup  (如果/usr/bin/没有python文件,则无需执行)

shell>ln -s /usr/python3.6.1/bin/python3 /usr/bin/python

shell>python -V

 

 

ps:

problem1:安装过程中,可能会报:can't decompress data; zlib not available错误

解决办法:yum install zlib zlib-devel  完成后重新编译安装python

 

problem2:django创建app,报No module named _sqlite3  

解决办法:yum install sqlite-devel  完成后重新编译安装python

 

problem3:安装完后import sll报错

解决办法:

#修改Setup文件
/Python-3.6.1/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

修改完成后重新编译安装。

 

posted @ 2017-06-15 15:50  Free-program  阅读(102)  评论(0)    收藏  举报