1. ホーム
  2. パイソン学習

AttributeError: 'module' オブジェクトには 'SSL_ST_INIT' という属性がありません。

2022-02-10 04:06:58
ubuntu@ubuntu:~$ pip install pyopenssl
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
    from pip._internal.commands import (
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/base_command.py", line 18, in <module>
    from pip._internal.download import PipSession
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 15, in <module>
    from pip._vendor import requests, six, urllib3
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
ubuntu@ubuntu:~$ sudo pip install -U pyopenssl
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
    from pip._internal.commands import (
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/base_command.py", line 18, in <module>
    from pip._internal.download import PipSession
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 15, in <module>
    from pip._vendor import requests, six, urllib3
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
ubuntu@ubuntu:~$ sudo python -m easy_install --upgrade pyOpenSSL
Searching for pyOpenSSL
Reading https://pypi.org/simple/pyOpenSSL/
Downloading https://files.pythonhosted.org/packages/01/c8/ceb170d81bd3941cbeb9940fc6cc2ef2ca4288d0ca8929ea4db5905d904d/pyOpenSSL- 19.0.0-py2.py3-none-any.whl#sha256=c727930ad54b10fc157015014b666f2d8b41f70c0d03e83ab67624fd3dd5d1e6
Best match: pyOpenSSL 19.0.0
Processing pyOpenSSL-19.0.0-py2.py3-none-any.whl
Installing pyOpenSSL-19.0.0-py2.py3-none-any.whl to /usr/local/lib/python2.7/dist-packages
writing requirements to /usr/local/lib/python2.7/dist-packages/pyOpenSSL-19.0.0-py2.7.egg/EGG-INFO/requires.txt
Adding pyOpenSSL 19.0.0 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/pyOpenSSL-19.0.0-py2.7.egg
Processing dependencies for pyOpenSSL
Finished processing dependencies for pyOpenSSL



主な参考文献は、このブログで、以下を参照しています。 https://www.e-learn.cn/content/wangluowenzhang/240918

には、複数のソリューションが存在します。

(1) 方法1.

pip uninstall pyopenssl
pip install pyopenssl

$ sudo pip install -U pyopenssl

(2) 方法2.

sudo python -m easy_install --upgrade pyOpenSSL

(3) 方法3: (私はこの方法を使用しています)

sudo pip install pyOpenSSL==16.2.0

(4) 方法4.

sudo pip install pyOpenSSL==16.2.0

 という結末になります。

すると、すべてうまくいきました。