Today I will show you how you can install NLTK ( Natural Language Toolkit ) on your Ubuntu 20.04 using Python.
What is NLTK – NLTK is a Python package that provides tools for Natural Language Processing. It provides many different algorithms, which are used to analyze the text and give the answer to questions like sentiment analysis, syntax parsing, part-of-speech tagging, etc.
It’s mainly used for linguistic data processing, which means it processes the data to extract the relevant information.
Before starting the installation make sure that you have root permissions for your ubuntu system, as we will need root permissions for installing NLTK.
Update and Upgrade
Okay, so the first step for us will be to update our index packages and also upgrade the downloaded latest packages, you can do that by entering these two commands given below in the terminal.
sudo apt-get update sudo apt-get upgrade
Now to Install NLTK you will need python and pip3 installed on your ubuntu, let’s see how you can install python and pip3 for installing NLTK.
Install Python and pip3
Now, installing python and pip3 is very easy, to begin first open a terminal window and type the command given below to install python –
sudo apt-get install python3
To install pip3 you will need to run this command –
sudo apt-get -y install python3-pip
Now after installing python and pip3, you can start the installation of NLTK on your ubuntu 20.04.
To install NLTK first open a terminal window and in the terminal window type the pip3 command given below which will start the download of NLTK on your ubuntu.
sudo pip3 install nltk
You might need to enter your password to use the sudo command, after entering your password, the download of nltk will start.
Once NLTK finishes downloading, you will need to import NLTK using the import command, you can do that by first entering the following command to open python.
After entering inside python you will need to use the import command. This will take a little bit of time.
Once the import finishes, the last step will be to download all the nltk packages using the nltk.download command, this will download all the packages you will need for nltk –
Now, if you want to uninstall NLTK from your ubuntu then you can do that by using pip3, the command format for uninstalling NLTK will be “ pip3 uninstall <package-name> “, where package name will be the name of the library/module that you want to uninstall.
pip3 uninstall nltk
This command will remove all the files associated with nltk.
That was it, that is how you can install NLTK on Ubuntu 20.04 using pip3, Here’s a post that might be of your interest – Install Anaconda on Ubuntu 20.04
If you are facing any problems while installing NLTK on your ubuntu 20.04 then comment below or send me a mail at – [email protected] Thank you.