I'm trying to write a basic script using nltk, which I've already installed with pip on my computer, but whenever I try to run my code with import nltk
at the top I keep getting a module not found error, this occurs with other programs I write as well, always at the first line, and I'm not sure what to do.
Asked
Active
Viewed 2,712 times
0

djc1223
- 45
- 1
- 6
-
It could be installed, but not in your current environment. Some more information about how you installed it and set up your environment or if you're using the default environment may be helpful. – Bobby May 05 '20 at 19:22
1 Answers
4
It's a common issue. You probably have multiple python versions and virtualenvs, so the pip install
might be installing packages for the wrong version. It's always best to use pip this way:
<python_command> -m pip install <package>
where python_command
is the same one that you run your scripts with, i.e. python
or python3
. This way you can be 100% sure that the package will be installed for the right python version / virtualenv.
See this answer for more detailed explanation.

RafalS
- 5,834
- 1
- 20
- 25