'AttributeError: 'module' object has no attribute '_create_unverified_context'

I got the following error

AttributeError: 'module' object has no attribute '_create_unverified_context'.

I'm using Python 3.4.2 .

My code:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

When I run this code, the error happens._create_unverified_context can be used in Python 3.4.2, so I really cannot understand why this error happens. How should I fix this? Traceback says

Traceback (most recent call last):
  File "quickstart.py", line 3, in <module>
    ssl._create_default_https_context = ssl._create_unverified_context()
AttributeError: 'module' object has no attribute '_create_unverified_context'


Solution 1:[1]

Are you sure _create_verified_context is an attribute and not a method? Have you tried:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context()

Solution 2:[2]

This error occurs if:

  • python version is less than 2.7 i
  • if the module being used isn't compatible with the python version being used

    Faced same issue when using module "pysphere" with python 2.7.3.

Just commenting out the line "ssl._create_default_https_context = ssl._create_unverified_context()" in the piece of code i had, worked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andreas
Solution 2 sushh