certificate verify failed: unable to get local issuer certificate

前端 未结 10 1174
梦如初夏
梦如初夏 2020-11-29 04:06

I am trying to get data from the web using python. I imported urllib.request package for it but while executing, I get error:

certificate verify failed: unab         


        
相关标签:
10条回答
  • 2020-11-29 05:06

    Paste the following code at the start:

    # paste this at the start of code
    import ssl 
    
    try:
        _create_unverified_https_context = ssl._create_unverified_context
    except AttributeError:
        pass
    else:
        ssl._create_default_https_context = _create_unverified_https_context
    
    0 讨论(0)
  • 2020-11-29 05:07

    I had the error with conda on linux. My solution was simple.

    conda install -c conda-forge certifi
    

    I had to use the conda forge since the default certifi appears to have problems.

    0 讨论(0)
  • 2020-11-29 05:08

    For those who this problem persists: - Python 3.6 (some other versions too?) on MacOS comes with its own private copy of OpenSSL. That means the trust certificates in the system are no longer used as defaults by the Python ssl module. To fix that, you need to install a certifi package in your system.

    You may try to do it in two ways:

    1) Via PIP:

    pip install --upgrade certifi
    

    2) If it doesn't work, try to run a Cerificates.command that comes bundled with Python 3.6 for Mac:

    open /Applications/Python\ 3.6/Install\ Certificates.command
    

    One way or another, you should now have certificates installed, and Python should be able to connect via HTTPS without any issues.

    Hope this helped.

    0 讨论(0)
  • 2020-11-29 05:09

    For anyone who still wonders on how to fix this, i got mine by installing the "Install Certificates.command"

    Here is how I did,

    Just double click on that file wait for it to install and in my case, you will be ready to go

    0 讨论(0)
提交回复
热议问题