I just updated to Python3... well, sort of. I can run both Python2.7.9 in the terminal and Python3. I also have NLTK3, which usually works with Python2.7, but there are some times when certain things don't work. Yet when I switch to Python3 in the MacOSX terminal, it won't let me import nltk (or anything else for that matter). Is there a simple fix for this?
>>> python 3
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'nltk'
On Mac OS X:
# Install pip
$ curl bootstrap.pypa.io/get-pip.py | python
$ curl bootstrap.pypa.io/get-pip.py | python3
On Ubuntu:
# Install pip
$ sudo apt-get install pip
$ sudo apt-get install pip3
Then:
# Install NLTK on python and python3
$ sudo pip install -U nltk
$ sudo pip3 install -U nltk
# Install Numpy
$ sudo pip install -U numpy
$ sudo pip3 install -U numpy
$ python
>>> import nltk
>>> nltk.download('all')
Libraries don't carry over between python versions.
You need to install that library for python 3 too.
Python 2 + Python 3 + library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With