A Python script of mine is failing with:
Traceback (most recent call last):
File \"./inspect_sheet.py\", line 21, in
main()
File \"./i
I was seeing similar python stack dump on the console of my Ubuntu 16.04 VM when I tried ssh into the VM.
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
pip
reported that pyopenssl
was not installed.
I had to do this instead:
sudo apt install --reinstall python-openssl
In my case, the problem was that the package was installed in root directories, and I was executing the script which asked for pyopenssl
with my Linux user forvas. And that user can't use the libraries installed in root.
So first I had to remove the package with aptitude
or apt-get
.
sudo aptitude purge python-openssl
Therefore, I had to install the package again, but taking into account the user who is executing the script which is asking for the library. Take a look to where the library is installed depending on the Linux user and the argument --user
of pip
.
Case 1
forvas@server:$ pip install pyopenssl
Could not install packages due to an EnvironmentError:
[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/OpenSSL'
Consider using the
--user
option or check the permissions.
Case 2
forvas@server:$ sudo pip install pyopenssl
/usr/local/lib/python2.7/dist-packages/OpenSSL/*
/usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*
Case 3
forvas@server:$ sudo pip install --user pyopenssl
/home/forvas/.local/lib/python2.7/site-packages/OpenSSL/*
/home/forvas/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*
Case 4
root@server:$ pip install pyopenssl
/usr/local/lib/python2.7/dist-packages/OpenSSL/*
/usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*
Case 5
root@server:$ pip install --user pyopenssl
/root/.local/lib/python2.7/site-packages/OpenSSL/*
/root/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*
Conclusion
My problem was that the library was installed in the directories of the case 5.
Solution
Uninstalling the package.
As I'm executing the script with Linux user forvas, I was able to reinstall the package rightly with the options 2 or 4 (in which the library is available for all Linux users) or more accurate, the option 3 (in which library is only available for Linux user forvas).