ubuntu 16.04 系统pip运行报错 'module' object has no attribute 'SSL_ST_INIT'
最近学习heperledger fabric,准备跑一下测试链,在运行脚本network.sh up时提示失败,内容如下:
1 Traceback (most recent call last): 2 File "/usr/bin/pip", line 11, in <module> 3 sys.exit(main()) 4 File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 18, in main 5 return _wrapper(args) 6 File "/usr/local/lib/python2.7/dist-packages/pip/_internal/utils/entrypoints.py", line 31, in _wrapper 7 return main(args) 8 File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/main.py", line 73, in main 9 command = create_command(cmd_name, isolated=("--isolated" in cmd_args)) 10 File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command 11 module = importlib.import_module(module_path) 12 File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 13 __import__(name) 14 File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/install.py", line 24, in <module> 15 from pip._internal.cli.req_command import RequirementCommand 16 File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/req_command.py", line 15, in <module> 17 from pip._internal.index.package_finder import PackageFinder 18 File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index/package_finder.py", line 21, in <module> 19 from pip._internal.index.collector import parse_links 20 File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index/collector.py", line 12, in <module> 21 from pip._vendor import html5lib, requests 22 File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 97, in <module> 23 from pip._vendor.urllib3.contrib import pyopenssl 24 File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module> 25 import OpenSSL.SSL 26 File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module> 27 from OpenSSL import rand, crypto, SSL 28 File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module> 29 SSL_ST_INIT = _lib.SSL_ST_INIT 30 AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
其实,我对Python不熟,看这个意思,应该就是openssl库有点问题,那就装一个呗,pip install pyopenssl。嗯?也报同一个错,然后还提示我,可以使用python -m pip ...,
好吧,我又跟着运行下命令:python -m pip install pyopenssl,然而还是不行,这让我懵逼了。
于是上网查查解决方法,解决方法大概都差不多,就是移除OpenSSL库文件夹,然后重装。嗯,好像有道理,然后我一看,我连这个文件夹/usr/lib/python2.7/dist-packages/OpenSSL都没有。
没有办法,我又继续找其他方法,诶,终于在google上找到了,运行下一下命令就解决了:
sudo python -m easy_install --upgrade pyOpenSSL
之后将不会出现以上错误,关于这个问题出现的原因,我之前的pip版本较老,有一次运行时,提示我更新到18.x.x版本,然后照做了,就有了接下来的问题。