-1

I'm a Linux Mint user who's been trying to import bs4 and nltk in VSCode and Sublime Text, but the error ImportError: No module named nltk [or bs4] always pops up. I've tried:

  1. importing them in the terminal, which somehow always works.
  2. Have tried changing the python path settings to python3.5 and python3.7, which doesn't fix the problem.
  3. I've also tried importing them in Sublime Text and the Reticulate package in R, both of which have resulted in failure.

But despite hours of trying and searching, it just does not seem to be working. Any help on the matter would be appreciated, thank you!

Diogo Rocha
  • 9,759
  • 4
  • 48
  • 52
user9006908
  • 113
  • 6

1 Answers1

1

Python search the modules in a series of locations, stored in sys.path. To know these locations, ① from the command line issue this command

$ python -c 'import sys ; [print(p) for p in sys.path]'

and ② into your editor enter the following text

import sys
for p in sys.path: print(p)

and execute it using the editor facilities.

Compare the outputs. If they are different you can try to understand why. Maybe a totally different interpreter, maybe a virtual environment, maybe you must come back to SO with the outputs and seek for further help. If they are equal... I couldn't guess what is happening.

gboffi
  • 22,939
  • 8
  • 54
  • 85