To fix the AttributeError: ‘module’ object has no attribute ‘SSL_ST_INIT’ error, “update the pyopenssl package.”
AttributeError: ‘module’ object has no attribute ‘SSL_ST_INIT’ error occurs in Python when you are “using an older version of OpenSSL library.”
The main reason for the error suggests that the version of the OpenSSL library you are using doesn’t recognize the attribute SSL_ST_INIT.
How to fix it?
If you use an older version of OpenSSL, you should “install/upgrade the pyOpenSSL package using pip.”
pip install --upgrade pyOpenSSL
You can check the installed versions of OpenSSL and pyOpenSSL using:
import OpenSSL print(OpenSSL.__version__) print(OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION))
23.2.0 b'OpenSSL 3.0.7 1 Nov 2022'
You can see that I am using a newer version of pyopenssl on my system.
An alternate way you can use is to upgrade pyopenssl with easy_install.
sudo python -m easy_install --upgrade pyopenssl
If the error is still not fixed, then you can try to uninstall the pyopenssl package and install it again.
pip uninstall pyopenssl pip install pyopenssl
This will surely fix the error and won’t interfere with existing packages.