Why shows error "import nltk"?

Question:

I was trying to build web crawler using python and I’v got following error when it executed.

import sys
import math
import re
from collections import OrderedDict, defaultdict
import os
import nltk //This line shows error
import pickle
from xml.dom import minidom
from xml.dom import EMPTY_NAMESPACE
import nltk  //This line shows error
from nltk.stem.porter import PorterStemmer
import time`enter code here`

How to overcome this problem?

Asked By: Dis_Pro

||

Answers:

try to install the package in your computer.

ubuntu:

sudo apt-get install python-nltk
Answered By: ori

First you can check whether already nltk you have installed or not.
Otherwise you can download from here.

NLTK download link

In ubuntu, you can try followng one:

sudo apt-get install python-nltk
Answered By: user3931893

use…

nltk.download('punkt')

…after you load nltk. You should be fine.

Answered By: Russ Harris
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.