Python Error

Resolving AttributeError 'module' object has no attribute 'SSL_ST_INIT' Error in Python

When programming in Python, you may encounter an error like 'AttributeError 'module' object has no attribute 'SSL_ST_INIT''. I didn't do anything special... it might be because I upgraded pip. The error 'AttributeError: 'module' object has no attribute 'SSL_ST_INIT'' suddenly started appearing when running python or pip...

Shou Arisaka
3 min read
Oct 11, 2025

When programming in Python, you may encounter an error like “AttributeError: ‘module’ object has no attribute ‘SSL_ST_INIT’”.

I didn’t do anything special, but - well, it might be because I upgraded pip (sudo pip install —upgrade pip) - suddenly the error AttributeError: ‘module’ object has no attribute ‘SSL_ST_INIT’ started appearing when running python or pip.

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 6, 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 20, 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.SSL
  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'
yuis ASUS /mnt/c/pg$ sudo pip install pyOpenSSL -U
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 6, 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 20, 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.SSL
  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'

After trying to execute code that seemed like it could solve it, the error disappeared with the following method.

sudo rm -r /usr/lib/python2.7/dist-packages/OpenSSL/
sudo pip install pyopenssl

openssl - Python AttributeError: ‘module’ object has no attribute ‘SSL_ST_INIT’ - Stack Overflow

I also tried the following two methods first, but they did not solve the error.

sudo apt-get --auto-remove --yes remove python-openssl
sudo pip install pyOpenSSL

python - Error with pip after upgrading : ‘module’ object has no attribute ‘SSL_ST_INIT’ - Stack Overflow

sudo pip install pyOpenSSL -U

python - AttributeError: ‘module’ object has no attribute ‘SSL_ST_INIT’ - Stack Overflow

Share this article

Shou Arisaka Oct 11, 2025

🔗 Copy Links