ModuleNotFoundError: No module named ‘nltk’, ‘sklearn’

I am trying to execute a program in Spyder. But getting errors as “module not found”. I also tried to install the modules using “pip” in sypder ipython console and windows command prompt, but still getting error as "pip " is not recognized

ModuleNotFoundError: No module named ‘nltk’
ModuleNotFoundError: No module named ‘sklearn’

!pip install --user -U nltk
‘pip’ is not recognized as an internal or external command,
operable program or batch file.

You will need to make sure pip is on your path variable. Each time you run Python you will have to make sure pip and python are on your path variable so they can be found.

You can also try this at the command line: python -m ensurepip --default-pip.

Pip might be on your system but the path variable is not correct.

I have not heard of Spyder. Oh it is an IDE for Python. You have to install the module so Spyder can find it. Follow the instructions in the link in the screenshot.

When you use what appears to be the Spyder shell, the Spyder shell probably is not setting up any path to the pip program so it cannot find it.

When posting please make sure to include this info:

  1. OS name and version.
  2. Python version.
  3. Any GUI you are using on Unix.
  4. Which IDE and version you are using if any. Like Pycharm, Visual Studio Code, etc.
1 Like

Please don’t post screenshots.

Copy and paste any code or traceback, and in order to preserve formatting, select the code or traceback that you posted and then click the </> button.

On Windows, it’s recommended that you use the Python Launcher py:

py -m pip install something