Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource punkt not found. Please use the NLTK Downloader to obtain the resource: #14

Open
subhobrata opened this issue Apr 14, 2019 · 29 comments

Comments

@subhobrata
Copy link

Got This Below error in Notebook 5_2_munging_frankenstein.ipynb
Please hep on this

LookupError Traceback (most recent call last)
in ()
----> 1 tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
2 with open(args.raw_dataset_txt) as fp:
3 book = fp.read()
4 sentences = tokenizer.tokenize(book)

/usr/local/lib/python3.6/dist-packages/nltk/data.py in load(resource_url, format, cache, verbose, logic_parser, fstruct_reader, encoding)
832
833 # Load the resource.
--> 834 opened_resource = _open(resource_url)
835
836 if format == 'raw':

/usr/local/lib/python3.6/dist-packages/nltk/data.py in open(resource_url)
950
951 if protocol is None or protocol.lower() == 'nltk':
--> 952 return find(path
, path + ['']).open()
953 elif protocol.lower() == 'file':
954 # urllib might not use mode='rb', so handle this one ourselves:

/usr/local/lib/python3.6/dist-packages/nltk/data.py in find(resource_name, paths)
671 sep = '*' * 70
672 resource_not_found = '\n%s\n%s\n%s\n' % (sep, msg, sep)
--> 673 raise LookupError(resource_not_found)
674
675

LookupError:


Resource punkt not found.
Please use the NLTK Downloader to obtain the resource:

import nltk
nltk.download('punkt')

Searched in:
- '/root/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
- '/usr/nltk_data'
- '/usr/lib/nltk_data'

@pmallari
Copy link

You can simply run

import nltk
nltk.download('punkt')

in the notebook to download the required files

@ds-manav
Copy link

ds-manav commented Oct 4, 2021

punkt is a nltk library tool for tokenizing text documents. When we use an old or a degraded version of nltk module we generally need to download the remaining data .
You can do
nltk.download('punkt')
nltk.download('stopwords')
nltk.download('corpus')

@EldhosePoulose
Copy link

You can simply run

import nltk
nltk.download('punkt')

in the notebook to download the required files

[nltk_data] Error loading punkt: <urlopen error [SSL:
[nltk_data] CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data] unable to get local issuer certificate (_ssl.c:1129)>

@ehous3
Copy link

ehous3 commented Mar 2, 2022

Got this same thing

@ehous3
Copy link

ehous3 commented Mar 2, 2022

Try this:

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()

@hassy97
Copy link

hassy97 commented May 31, 2022

import nltk
nltk.download('punkt')

work for me thanks :)

@AfeJohn
Copy link

AfeJohn commented Jun 27, 2022

You can simply run

import nltk
nltk.download('punkt')

in the notebook to download the required files

This worked for me thanks.

@chethankailash
Copy link

You can simply run

import nltk
nltk.download('punkt')

in the notebook to download the required files

This worked for me too. Thanks!
In terminal,
$python3

import nltk
nltk.download('punkt')

@MrRunShu
Copy link

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()

work for me thanks:)

@lagraham337
Copy link

I am receiving this error as well and have tried everything in the comments.

@UjjwalAnand364
Copy link

UjjwalAnand364 commented Dec 18, 2022

An easy way to get over this 'urlopen error' is to do the process manually. Just go to the website https://www.nltk.org/nltk_data/ and download the required zip file and extract the contents.

In Windows, go to user/AppData/local/Programs/Python/Python(version)/lib and create a folder nltk_data. Then create the respective folder. As an example, for 'punkt' create the folder tokenizers and add the folder 'punkt' inside the extracted folder to it. This info is mostly given by the terminal itself.

Run your program. Cheers!

EDIT 1: Of course, downloading all files can be time-consuming, but it's the only option if the "urlopen error" persists.

EDIT 2 It is also mostly your router or network at fault that you are not able to download nltk files. Try changing your network and that should help.

@prajwal13579
Copy link

I am receiving this error as well and have tried everything in the comments.

TRY CHANGING YOUR NETWORK
--> i had the same problem where none of the recommended solutions worked until i changed my wifi. I simply used another network and it worked for me. I don't know why this worked but i hope it helps you.

@prajwal13579
Copy link

You can simply run

import nltk
nltk.download('punkt')

in the notebook to download the required files

[nltk_data] Error loading punkt: <urlopen error [SSL: [nltk_data] CERTIFICATE_VERIFY_FAILED] certificate verify failed: [nltk_data] unable to get local issuer certificate (_ssl.c:1129)>

TRY CHANGING YOUR NETWORK
--> i had the same problem where none of the recommended solutions worked until i changed my wifi. I simply used another network and it worked for me. I don't know why this worked but i hope it helps you.

@usmanyousaaf
Copy link

Code downloads Punkt tokenizer successfully for me
import nltk
nltk.download('punkt')

@thesakshidiggikar
Copy link

need help!
I tried every single method that is mentioned or recommended by you all, still can't figure out what should I do now, I made a new file in pythin\lib directly suggested above and also tried to write nltk.download('punkt')
none of them worked for me.
image

@usmanyousaaf
Copy link

usmanyousaaf commented Feb 14, 2023

need help! I tried every single method that is mentioned or recommended by you all, still can't figure out what should I do now, I made a new file in pythin\lib directly suggested above and also tried to write nltk.download('punkt') none of them worked for me. image

Try This:

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()

OR

  • Manually Download the NLTK Data Packages Link

@mohammed-hasan007
Copy link

Getting this error guys. Any help would be very helpful. Thanks in advance

nltk.download('punkt')
[nltk_data] Error loading punkt: <urlopen error [Errno 54] Connection
[nltk_data] reset by peer>
False

@UjjwalAnand364
Copy link

As mentioned by several people here including me, the primary cause of this error underlies to a faulty/unstable network connection.
The code:

import nltk
nltk.download('punkt')

works fine.
I too had the same problem wherein I was unable to download the resources, and consequently it didn't install in the desired repository. Try changing your network, remove the firewall or use a VPN. Any of these WILL work.

@ibrahim-string
Copy link

It works fine if the network conection is stable otherwise it crashes .
It worked for me :)

@pmarathay
Copy link

I ran into the same problem but just needed to add the code mentioned above (plus a few additional lines) to get it to work.

Here is the original code:
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize, sent_tokenize
from nltk.tag import pos_tag

Here is the modified and working code:
import nltk
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
nltk.download('stopwords')
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize, sent_tokenize
from nltk.tag import pos_tag

You'll notice i just added 3 lines. The first is based on the comments above and the other two were derived by extension of the same logic.
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
nltk.download('stopwords')

Hope this helps!

@iamrohansood
Copy link

need help! I tried every single method that is mentioned or recommended by you all, still can't figure out what should I do now, I made a new file in pythin\lib directly suggested above and also tried to write nltk.download('punkt') none of them worked for me. image

Try This:

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()

OR

  • Manually Download the NLTK Data Packages Link

I've downloaded it manually what to do next

@kbrajwani
Copy link

i face the same issue. The main issue is that we are not able to connect the raw github url. Where NLTK will download the data.
Check bu hitting this url. If you not able to open it. we have the same problem.
https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/corpora/brown.zip

You can use following tutorial to solve this issue.
https://www.debugpoint.com/failed-connect-raw-githubusercontent-com-port-443/#:~:text=Fix%201%3A%20Updating%20the%20%2Fetc%2Fhosts%20file%20in%20Linux,-If%20you%20are&text=Open%20the%20%2Fetc%2Fhosts%20file.&text=Then%20at%20the%20end%20of%20this%20file%2C%20add%20the%20IP%20address.&text=Save%20and%20close%20the%20file,again%2C%20and%20it%20should%20work.

@ravijammi
Copy link

need help! I tried every single method that is mentioned or recommended by you all, still can't figure out what should I do now, I made a new file in pythin\lib directly suggested above and also tried to write nltk.download('punkt') none of them worked for me. image

Try This:

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()

OR

  • Manually Download the NLTK Data Packages Link

This solution worked for me as well.

@daviibf
Copy link

daviibf commented Oct 2, 2023

punkt is a nltk library tool for tokenizing text documents. When we use an old or a degraded version of nltk module we generally need to download the remaining data . You can do nltk.download('punkt') nltk.download('stopwords') nltk.download('corpus')

This worked for me !

@varunpalakodeti20
Copy link

Try this:

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()

This works!!!!1

@charmingjill
Copy link

Try this:

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()

you're god!

@SHIsue
Copy link

SHIsue commented Jan 4, 2024

An easy way to get over this 'urlopen error' is to do the process manually. Just go to the website https://www.nltk.org/nltk_data/ and download the required zip file and extract the contents.

In Windows, go to user/AppData/local/Programs/Python/Python(version)/lib and create a folder nltk_data. Then create the respective folder. As an example, for 'punkt' create the folder tokenizers and add the folder 'punkt' inside the extracted folder to it. This info is mostly given by the terminal itself.

Run your program. Cheers!

EDIT 1: Of course, downloading all files can be time-consuming, but it's the only option if the "urlopen error" persists.

EDIT 2 It is also mostly your router or network at fault that you are not able to download nltk files. Try changing your network and that should help.

this help!!!!

@craterr
Copy link

craterr commented Mar 25, 2024

🪲Its a bug , add these parameters to the word_tokenize function
example->
tokens = nltk.word_tokenize(example, language='english', preserve_line=True)
This worked for me.

@khaibenz
Copy link

I solved this by providing an absolute path (as I needed to perform calculations on a remote server that didn't have an internet connection).

Download the resource you need and save it under /home/user/nltk_data/ (this is where nltk will look per default)

For example /home/user/nltk_data/tokenizers/punkt/english.pickle

import nltk
nltk.data.load('absolute/path/to/your/resource', verbose=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests