0

I started working with the NLTK 3.0 module for Python 2.7. I have recently shifted to Python 3.6. NLTK 3.0 is compatible with both.

When I try to import NLTK using Python 3.6 (in the IDLE integrated development environment), I get the error:

    import nltk
ModuleNotFoundError: No module named 'nltk'

My question: How do I make the NLTK module available to Python 3.6 without re-downloading the module?

I think it might be as easy as changing the locations of the NLTK files, is this correct?


This question is very similar to this off-topic question:

Python: how to get different versions of python to access the same modules?

except that, unlike scitools, NLTK is compatible with both Python 2.7 and Python 3.6.

Community
  • 1
  • 1
DyingIsFun
  • 1,227
  • 2
  • 10
  • 21

1 Answers1

1

It is compatible to both, but you still need to install it for your specific python version (I'm having this problem all the time; having packages installed for another python2.x whereas I thought I installed it for python3.x or the other way round). Usually, (if you're running python3.x now), doing something like

sudo pip3 install nltk

does the trick. By "without re-downloading the module", do you mean the nltk_data folder? I'm not sure, but think that is by default put in your home folder and can be shared between different python versions. And just doing a pip install shouldn't take too long/there's not that much to download I think.

Igor
  • 1,251
  • 10
  • 21
  • Thanks, this is helpful! But first I must get the pip3 command, which the following is helping me to do: https://stackoverflow.com/questions/11268501/how-to-use-pip-with-python-3-x-alongside-python-2-x – DyingIsFun Dec 27 '16 at 14:31
  • Ah yes of course. Usually the apt-get install python3-pip worked pretty good for me. – Igor Dec 27 '16 at 14:43