title: "WindowsError: [Error 5] Access is denied" using urllib2
body: <p>I'm getting a "WindowsError: [Error 5] Access is denied" message when reading a website with urllib2. </p>
  
  <pre><code>from urllib2 import urlopen, Request
  from bs4 import BeautifulSoup
  
  hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'}
  req = Request('https://' + url, headers=hdr)
  soup = BeautifulSoup( urlopen( req ).read() )
  </code></pre>
  
  <p>The full traceback is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "C:\Python27\lib\urllib2.py", line 154, in urlopen
      return opener.open(url, data, timeout)
    File "C:\Python27\lib\urllib2.py", line 431, in open
      response = self._open(req, data)
    File "C:\Python27\lib\urllib2.py", line 449, in _open
      '_open', req)
    File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
      result = func(*args)
    File "C:\Python27\lib\urllib2.py", line 1240, in https_open
      context=self._context)
    File "C:\Python27\lib\urllib2.py", line 1166, in do_open
      h = http_class(host, timeout=req.timeout, **http_conn_args)
    File "C:\Python27\lib\httplib.py", line 1258, in __init__
      context = ssl._create_default_https_context()
    File "C:\Python27\lib\ssl.py", line 440, in create_default_context
      context.load_default_certs(purpose)
    File "C:\Python27\lib\ssl.py", line 391, in load_default_certs
      self._load_windows_store_certs(storename, purpose)
    File "C:\Python27\lib\ssl.py", line 378, in _load_windows_store_certs
      for cert, encoding, trust in enum_certificates(storename):
  WindowsError: [Error 5] Access is denied
  </code></pre>
  
  <p>I've tried running the script from a command prompt with admin privileges, as suggested <a href="https://stackoverflow.com/questions/28528020/why-am-i-getting-windowserror-error-5-access-is-denied">here</a>, but it does not fix the problem.</p>
  
  <p>Any suggestions on how to resolve this error?</p>