Python Forum
[split] serious n00b.. NLTK in python 2.7 and 3.5 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: [split] serious n00b.. NLTK in python 2.7 and 3.5 (/thread-8483.html)



[split] serious n00b.. NLTK in python 2.7 and 3.5 - kevindenman - Feb-22-2018

Hi All,

I am a python noob (comparable to when this thread was first started) trying to get NLTK up and running as my first Python application.

I have both python 2.7.10 and 3.6.4 installed. I think I somehow installed NLTK into the wrong version of Python and I have been unable to get the NLTK module in python3. I have installed a bunch of packages in Python3 (matplotlib, math, numpy) and want to make sure I am ONLY coding in Python3 going forward.

Any help getting my foundation right would be really helpful! I'm in circles now with the python version -- module install alignment.

From Terminal:

--- python --- module is found

Kevins-MBP:~ kevin$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>

--- python3 --- module not found

Kevins-MBP:~ kevin$ python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'nltk'
>>>


RE: [split] serious n00b.. NLTK in python 2.7 and 3.5 - sparkz_alot - Feb-22-2018

Have you tried pip3 install module_name or perhaps pip3.6 install module_name ?

If you are getting an error, please post the entire error (between the error tags)


RE: [split] serious n00b.. NLTK in python 2.7 and 3.5 - snippsat - Feb-22-2018

You could have mention that you use Mac.
Doing it Right
Quote:Homebrew installs pip3 for you.
pip3 is the alias to pip pointing to the Homebrew’d Python 3.

I would mention pyenv the best version management to use,
and safe it do not mess with system Python installation.

Examle Linux,work the same on Mac.
# Install
mint@mint ~ $ pyenv install 3.6.4
Downloading Python-3.6.4.tar.xz...
-> https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
Installing Python-3.6.4...
Installed Python-3.6.4 to /home/mint/.pyenv/versions/3.6.4

# Set python and pip to point to 3.6.4
mint@mint ~ $ pyenv global 3.6.4
mint@mint ~ $ python -V
Python 3.6.4
mint@mint ~ $ pip -V
pip 9.0.1 from /home/mint/.pyenv/versions/3.6.4/lib/python3.6/site-packages (python 3.6)
# Finish



RE: [split] serious n00b.. NLTK in python 2.7 and 3.5 - kevindenman - Feb-22-2018

Thanks for the responses! Sorry snippsat, will try to add more relevant info to future posts.

For background, I successfully followed all of the steps here to get Python3 setup: How To Install Python 3 and Set Up a Local Programming Environment on macOS. This included setting up an environment to manage python projects. Is pyenv a better way to do what they recommended in "Step 5 — Creating a Virtual Environment"?

@sparkz_alot - I tried
pip3 install nltk
and it seems to think the package is already there. When I fire up python3 and try to import nltk, it says it cannot find it.

I think I maybe installed nltk in an environment I had set up at the link below? I am just getting familiar with all this, so it's possible I implemented the environment but am failing to navigate it properly.

Kevins-MBP:~ kevin$ python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
Kevins-MBP:~ kevin$ pip3 install nltk
Requirement already satisfied: nltk in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from nltk)
Kevins-MBP:~ kevin$ python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'nltk'
>>>