Linux上python安装完毕后,用pip安装模块提示找不到ssl模块:
2018-03-23 14:59
796 查看
1.Linux上报错为:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting xxx
Could not fetch URL https://pypi.python.org/simple/xxxx/: There was a problem confirming the ssl certificate: Can’t connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement xxx (from versions: )
No matching distribution found for xxx
2.这是由于在openssl安装包,缺少openssl-devel包 ,通过rpm -aq|grep openssl 命令查看:
[root@localhost ~]# rpm -aq|grep openssl
openssl-1.0.2k-8.el7.x86_64
openssl-libs-1.0.2k-8.el7.x86_64
[root@localhost ~]#
3.然后可以通过yum来安装:
yum install openssl-devel -y
查看安装结果:
[root@localhost ~]# rpm -aq|grep openssl
openssl-devel-1.0.2k-8.el7.x86_64
openssl-1.0.2k-8.el7.x86_64
openssl-libs-1.0.2k-8.el7.x86_64
执行yum可能出现的情况:(安装成功则跳过,到第4步)
这里有可能还会出现一个问题,运行yum的任何命令是报语法错误:
$ yum File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax
这是因为yum采用python作为命令解释器,这可以从/usr/bin/yum文件中第一行#!/usr/bin/python发现。
而python版本之间兼容性不太好,使得2.X版本与3.0版本之间存在语法不一致问题。
CentOS 7自带的yum采用的是python2.7,当系统将python升级到2.7或3.x后,出现语法解释错误。
解决办法: 很简单,一是升级yum,一是修改yum的解释器为旧版本python2.7(如果你没有采用覆盖升级的话)。 升级yum的作法就不详述了。修改yum的解释器为旧版本python2.7(看各人的旧版本是哪个就修改为哪个): $ vi /usr/bin/yum 将第一行"#!/usr/bin/python" 改为 "#!/usr/bin/python2.7"即可。 再次运行yum命令,就不回再报错了。 如果运行后报以下错误File "/usr/libexec/urlgrabber-ext-down", line 28 except OSError, e: 就修改/usr/libexec/urlgrabber-ext-down文件,将python同样指向旧版本,就可以了
4.重新编译python,找到python的安装包修改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
修改后编译安装make
make install
安装成功,就能正常使用了。
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting xxx
Could not fetch URL https://pypi.python.org/simple/xxxx/: There was a problem confirming the ssl certificate: Can’t connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement xxx (from versions: )
No matching distribution found for xxx
2.这是由于在openssl安装包,缺少openssl-devel包 ,通过rpm -aq|grep openssl 命令查看:
[root@localhost ~]# rpm -aq|grep openssl
openssl-1.0.2k-8.el7.x86_64
openssl-libs-1.0.2k-8.el7.x86_64
[root@localhost ~]#
3.然后可以通过yum来安装:
yum install openssl-devel -y
查看安装结果:
[root@localhost ~]# rpm -aq|grep openssl
openssl-devel-1.0.2k-8.el7.x86_64
openssl-1.0.2k-8.el7.x86_64
openssl-libs-1.0.2k-8.el7.x86_64
执行yum可能出现的情况:(安装成功则跳过,到第4步)
这里有可能还会出现一个问题,运行yum的任何命令是报语法错误:
$ yum File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax
这是因为yum采用python作为命令解释器,这可以从/usr/bin/yum文件中第一行#!/usr/bin/python发现。
而python版本之间兼容性不太好,使得2.X版本与3.0版本之间存在语法不一致问题。
CentOS 7自带的yum采用的是python2.7,当系统将python升级到2.7或3.x后,出现语法解释错误。
解决办法: 很简单,一是升级yum,一是修改yum的解释器为旧版本python2.7(如果你没有采用覆盖升级的话)。 升级yum的作法就不详述了。修改yum的解释器为旧版本python2.7(看各人的旧版本是哪个就修改为哪个): $ vi /usr/bin/yum 将第一行"#!/usr/bin/python" 改为 "#!/usr/bin/python2.7"即可。 再次运行yum命令,就不回再报错了。 如果运行后报以下错误File "/usr/libexec/urlgrabber-ext-down", line 28 except OSError, e: 就修改/usr/libexec/urlgrabber-ext-down文件,将python同样指向旧版本,就可以了
4.重新编译python,找到python的安装包修改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
修改后编译安装make
make install
安装成功,就能正常使用了。
相关文章推荐
- python安装完毕后,提示找不到ssl模块的解决步骤
- python安装完毕后,提示找不到ssl模块的解决步骤
- python安装完毕后,提示找不到ssl模块的解决步骤
- Python安装完毕后,提示找不到ssl模块的解决步骤
- python安装完毕后,提示找不到ssl模块的解决步骤
- python安装完毕后,提示找不到ssl模块的解决步骤
- python3 执行pip3 install requests ,提示找不到ssl模块
- python安装好后,提示找不到ssl模块
- python安装完毕后,用pip安装 提示找不到ssl模块
- python安装完毕后,用pip安装 提示找不到ssl模块
- python3的安装过程,以及使用pip3安装出错,提示错误找不到SSL
- Python3中pip3安装模块出错,找不到SSL
- [置顶] linux-ubuntu-kail-pip-ssl模块未安装
- Linux升级Python提示Tkinter模块找不到解决[转载]
- python3中pip3安装出错,找不到SSL
- ubuntu下使用pip3.6安装模块总是报ssl module in Python is not available的错误
- Linux升级Python提示Tkinter模块找不到解决
- 【linux】安装gae时提示安装python-gevent
- python cx_Oracle模块的安装和使用(linux环境)
- Linux 下安装python软件包(pip、nose、virtualenv、distribute )