Djangoをバージョンアップしたら AttributeError: module 'lib' has no attribute 'SSL_ST_INIT' が出た
Django 1.10.1 から 1.10.5にバージョンアップしたところ、サーバ起動中に以下のエラーが出た。
File "/Users/omega/xxx/client.py", line 2, in <module> import requests File "/Users/omega/venv/lib/python3.6/site-packages/requests/__init__.py", line 84, in <module> from urllib3.contrib import pyopenssl File "/Users/omega/venv/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module> import OpenSSL.SSL File "/Users/omega/venv/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module> from OpenSSL import rand, crypto, SSL File "/Users/omega/venv/lib/python3.6/site-packages/OpenSSL/SSL.py", line 118, in <module> SSL_ST_INIT = _lib.SSL_ST_INIT AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'
2つくらい前のバージョンが入ってたので最新のものを入れ直した。
これで無事サーバが起動した。
$ pip uninstall pyOpenSSL $ pip install pyOpenSSL $ pip show pyOpenSSL Name: pyOpenSSL Version: 17.3.0 Summary: Python wrapper module around the OpenSSL library Home-page: https://pyopenssl.org/ Author: Hynek Schlawack Author-email: hs@ox.cx License: Apache License, Version 2.0 Location: /Users/omega/venv/lib/python3.6/site-packages Requires: six, cryptography
たまーに遭遇するエラー。pyOpenSSLは定期的にアップデートしたほうがよいかも。
深く調べる体力はなかった。