CentOS 6.8 安装 Python3

由于没有GCC无法编译安装Python3.6, 所以先安装GCC(yum install gcc)

下载地址:https://www.python.org/ftp/python/


1 tar zxvf Python-3.5.2.tgz

2 cd Python-3.5.2

3 ./configure --prefix=/usr/local/python35

4 make && make install

然后安装pip3,然后用pip3安装包的时候遇到:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. 

解决办法:

# rpm -aq|grep openssl

1). yum install openssl-devel -y

     yum install openssl

      yum libssl-dev

2). 

#修改Setup文件
vi /usr/software/Python-2.7.5/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

3). 重新编译安装Python3

 ./configure --enable-optimizations

    make altinstall

4). 可以正常用pip3安装包了。

I ran into the same error when building Python 3.6.1 from source under CentOS 7. For CentOS7, I had to first:

sudo yum install openssl-dev

Then:

./configure --enable-optimizations
make altinstall

Now pip3.6 works :-)

 

refer: https://stackoverflow.com/questions/41489439/pip3-installs-inside-virtual-environment-with-python3-6-failing-due-to-ssl-modul

如果您认为这篇文章还不错或者有所收获,您可以通过右边的“打赏”功能 打赏我一杯咖啡【物质支持】,也可以点击下方的【好文要顶】按钮【精神支持】,因为这两种支持都是使我继续写作、分享的最大动力!

原文地址:https://www.cnblogs.com/kex1n/p/8270261.html