Cannot import nltk 3.0.5 on Windows

1,661 views
Skip to first unread message

Justin So

unread,
Sep 7, 2015, 9:13:54 PM9/7/15
to nltk-users
Hi, I have Python 3.4.3 (32-bit) installed on my PC. After installing nltk 3.0.5, I tried to import it, and then I got this error message:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import nltk
  File "C:\Python34\lib\site-packages\nltk\__init__.py", line 129, in <module>
    from nltk.chunk import *
  File "C:\Python34\lib\site-packages\nltk\chunk\__init__.py", line 157, in <module>
    from nltk.chunk.api import ChunkParserI
  File "C:\Python34\lib\site-packages\nltk\chunk\api.py", line 13, in <module>
    from nltk.parse import ParserI
  File "C:\Python34\lib\site-packages\nltk\parse\__init__.py", line 77, in <module>
    from nltk.parse.malt import MaltParser
  File "C:\Python34\lib\site-packages\nltk\parse\malt.py", line 12, in <module>
    from six import text_type
ImportError: No module named 'six'

I have PYTHONPATH and Path pointing to my python directory as well. 

I was able to import nltk on both Ubuntu and OS X. 

Please let me know how to fix it. Thanks!

Steven Bird

unread,
Sep 7, 2015, 9:16:29 PM9/7/15
to nltk-users
I'm surprised that six was not installed automatically. Please try installing six and then try NLTK again.




--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin So

unread,
Sep 7, 2015, 10:57:11 PM9/7/15
to nltk-users
Thanks! It fixed the issue.

I also tested a windows machine that had NLTK 3.0.4 installed. It also had the same issue after I upgraded it to 3.0.5. 

Dmitrijs Milajevs

unread,
Sep 17, 2015, 7:47:10 PM9/17/15
to nltk-users
Hi,
Hello,

What did you use to install NLTK?

I've tried running

  python -m pip install nltk

and it picket up six as a dependency, you should see the following lines in pip output:

  Collecting six>=1.9.0 (from nltk)
  Downloading six-1.9.0-py2.py3-none-any.whl

If you copied nltk distribution content into C:\Python34\lib\site-packages\nltk then indeed you miss six, you can install it with the following command (but better install nltk with the command above):

   python -m pip install six

I might miss some details, as I don't work with Windows regularly.

Justin So

unread,
Sep 17, 2015, 7:58:55 PM9/17/15
to nltk-users
On Windows, in general I use an executable file to install nltk, as suggested on the website. It seems like six needs to be installed manually, if using the executable. I don't run python much on Windows, so I wasn't aware that using command prompt to install nltk would trigger the installation of six. It's good to know, though. Thanks. 

Pilar Santolaria

unread,
Oct 6, 2015, 12:15:02 PM10/6/15
to nltk-users
Hello, 

I don't know much about programming, but I'm learning NLTK with Python on Windows and I use the IDLE interpreter. I've installed Python's latest version (3.5.0) and, as others said in this discussion, it seems to be a problem with module "six". I've downloaded the following file: "six-1.9.0-py2.py3-none-any.whl (md5)" from the web you recommended. It may be very basic, but how do I install "six"? In which folder do I have to copy the downloaded file? I've tried copying it in the folder "Lib" from the Python's directory and then trying: "import six" on the IDLE but it doesn't work. how can I install it easily?
I would very much appreciate any kind of help. 

Thank you!

El dimarts, 8 setembre de 2015 3:16:29 UTC+2, Steven Bird va escriure:

Tah Wei Hoon

unread,
Oct 6, 2015, 1:32:07 PM10/6/15
to nltk-users
Hi Pilar,

For now, you have to manually install Six through the command line.

1. Open the command prompt as Administrator
Click Start menu, type cmd, right-click on Command Prompt, and select "Run as Administrator"

2. In the command prompt, type
"C:\Program Files (x86)\Python3.5.0\Scripts\pip" install six
This assumes that Python is installed in C:\Program Files (x86)\Python3.5.0. If not, replace it with where you installed Python.

Steven Bird

unread,
Oct 7, 2015, 6:47:36 PM10/7/15
to nltk-users
Note that we are side-stepping this problem in NLTK 3.1 (due out in a few days), by incorporating the "six" package in NLTK.
--

--
Sent from my phone, please excuse miscorrected typos

Pilar Santolaria

unread,
Oct 8, 2015, 11:15:58 AM10/8/15
to nltk-users
Hi!

Thank you a lot for your help!!

El dimarts, 6 octubre de 2015 19:32:07 UTC+2, Tah Wei Hoon va escriure:
Reply all
Reply to author
Forward
0 new messages