NameError: name 'ssl' is not defined
global name 'ssl' is not defined
Global name 'ssl' is not defined - Part 1 (2017) - fast.ai Course Forums
amazon web services - aws cli commands - `fatal error: name 'ssl' is not defined` - Stack Overflow
On Mac OS X, the problem is resolved by clicking on the "Install Certificates.command" file located in the Python directory of the Applications folder.
To run the command, open a new Finder window. Click on "Applications". Then click on the directory where Python is installed. For example, "Python 3.7". Finally, kick on the "Install Certificates.command file.
All of this can be accomplished by executing the following command in the Terminal application:
pythonCopyopen "/Applications/Python 3.7/Install Certificates.command"
NOTE: You need to be logged into the account that downloaded and installed Python 3.7.
The sslopt={"cert_reqs": ssl.CERT_NONE} way is correct. When you get a NameError: NameError: name 'ssl' is not defined you need to import ssl
and it should work. Worked for my SSL-related problem.
Unrelated to the original question, but because this is the first Google result... I hit this on Google AppEngine and had to add:
libraries:
- name: ssl
version: latest
to app.yaml per: https://cloud.google.com/appengine/docs/python/sockets/ssl_support
Please NOTE: This seems to work upto Python version 2.7.9 but not for 2.7.10 or 2.7.11.
Since --with-ssl is not recognized anymore I just installed the libssl-dev.
For debian based systems:
sudo apt-get install libssl-dev
For CentOS and RHEL
sudo yum install openssl-devel
To restart the make first clean up by:
make clean
Then start again and execute the following commands one after the other:
./configure
make
make test
make install
For further information on OpenSSL visit the Ubuntu Help Page on OpenSSL.
Hi! I'm using gspread to download the contents of a number of Google Sheets, and occasionally it will throw a ssl.SSLError:
ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2555)
It's an error that seems to be random. Sometimes I may not get the error at all, and if I try the exact same google sheet download a few seconds later, it usually works just fine, or it may fail for a different sheet, all without making any script edits.
What I want to do is capture the ssl.SSLError in a try/except, but using either
except SSLError:
or
except ssl.SSLError:
results in another error along the lines of:
NameError: global name 'SSLError' is not defined
How do I go about catching just this specific SSLError without getting too generic with the "except" statement? I just want to catch that one type of error so I can automate a limited retry loop for that one file and then continue on to get the rest. I've looked into gspread's exceptions, but obviously none of them extend to the level of ssl failing.
Thanks!
I believe your file is named socket.py, and this produces the error (python confuses the name of your file with another socket, part of ssl module which it needs to import, thus having the namespace type of error).
Rename your file to something else (my_socket.py) and the problem should go away.
Below link will sloves your problem
https://techglimpse.com/install-python-openssl-support-tutorial/