0

I am trying to install nltk package on my machine, it encounter the following error:

!pip3 install nltk
import nltk
nltk.download('punkt')
nltk.download('wordnet')
nltk.download('stopwords')
nltk.download('abc')
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer
from nltk.corpus import stopwords
Requirement already satisfied: nltk in /usr/local/lib/python3.9/site-packages (3.6.1)
Requirement already satisfied: regex in /usr/local/lib/python3.9/site-packages (from nltk) (2021.4.4)
Requirement already satisfied: tqdm in /usr/local/lib/python3.9/site-packages (from nltk) (4.60.0)
Requirement already satisfied: joblib in /usr/local/lib/python3.9/site-packages (from nltk) (1.0.1)
Requirement already satisfied: click in /usr/local/lib/python3.9/site-packages (from nltk) (7.1.2)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-15-e70099103d37> in <module>
      1 get_ipython().system('pip3 install nltk')
----> 2 import nltk
      3 nltk.download('punkt')
      4 nltk.download('wordnet')
      5 nltk.download('stopwords')

ModuleNotFoundError: No module named 'nltk'

I have never had a problem with my package installing till now.. I don't know why it happens, is it because I am using python 3.9?

Sheldon
  • 169
  • 1
  • 2
  • 12
  • I just tried from inside jupyterlab with python 3.9.1 and could not reproduce your issue. Could you give us more information about your environment? What are the outputs of `from platform import python_version print(python_version())` , `! pip3 -V`, and `! which jupyter` if you're using jupyter? Are you intending to run in any sort of virtual environment? – Frodnar Apr 08 '21 at 20:36
  • Python version: 3.8.4 pip version: pip 21.0.1 from /usr/local/lib/python3.9/site-packages/pip (python 3.9) Jupyter: jupyter not found (I was using Jupyter through VS code, not web based version jupyter) – Sheldon Apr 08 '21 at 21:11
  • Seems like have multiple python3 versions installed `pip3` is installing to one version while your IPython kernel is using a different version. Try reading [this thread](https://stackoverflow.com/questions/58645807/change-interpreter-in-jupyter-notebook) and the solutions proposed. – Frodnar Apr 08 '21 at 21:17
  • Hi, I would like to delete the 3.8 version python and find the path for 3.9 so I can add to VS code Interpreter.. how would I do that? I tried which python, where python, it didn't seem to work.. ( I am working with Mac by the way) – Sheldon Apr 08 '21 at 21:31
  • 1
    @Frodnar Thank you, all figured out! – Sheldon Apr 08 '21 at 22:00

0 Answers0