SSL error downloading NLTK data

前端 未结 4 1582
梦如初夏
梦如初夏 2020-12-02 06:02

I am trying to download NLTK 3.0 for use with Python 3.6 on Mac OS X 10.7.5, but am getting an SSL error:

import nltk
nltk.download()

相关标签:
4条回答
  • 2020-12-02 06:06

    In Finder, search for Python 3.6. It will appear under Application folder. Expand the Python 3.6 folder. Then install certificates using "Install Certificates.command".

    enter image description here

    0 讨论(0)
  • 2020-12-02 06:09

    To install in codestar only way is manually download modules and save them into nltk_data folder, create a lambda variable environment NLTK_DATA with valie ./nltk_data.

    0 讨论(0)
  • 2020-12-02 06:16

    Please see answer by @doctorBroctor. It is more correct and safer to use. Leaving answer below as it might be useful for something else.

    https://stackoverflow.com/a/42890688/1167890


    This will work by disabling SSL checking.

    import nltk
    import ssl
    
    try:
        _create_unverified_https_context = ssl._create_unverified_context
    except AttributeError:
        pass
    else:
        ssl._create_default_https_context = _create_unverified_https_context
    
    nltk.download()
    
    0 讨论(0)
  • 2020-12-02 06:32

    You don't need to disable SSL checking if you run the following terminal command:

    /Applications/Python 3.6/Install Certificates.command
    

    In the place of 3.6, put your version of Python if it's an earlier one. Then you should be able to open your Python interpreter (using the command python3) and successfully run nltk.download() there.

    This is an issue wherein urllib uses an embedded version of OpenSSL that not in the system certificate store. Here's an answer with more information on what's going on.

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