So unfortunately for us inexperienced programmers, even just downloading, installing and running Python and NLTK is no walk in the park. It took me quite a few attempts before I knuckled down and found all the answers to my questions. It really wasn’t as simple as going to the NLTK website and following their instructions because their instructions don’t work! But lucky you I have already figured it out so you can follow my instructions.
The way I’ve done this is I’ve listed the steps I followed as well as alternatives in case they don’t work for you. Here goes!
- First off, you need to install Python 3.5. Install the most recent version of 3.5 which is 3.5.4. You need the 32-bit version. Even if your computer is 64-bit, NLTK only works with the 32-bit. Select the Windows x86 executable installer (of course, not the Windows x86-64 one because that is the 64-bit version) and download it. Follow the installer, don’t worry about making any changes to the pre-selected options because they work fine.
- Now comes the more complicated part, the part that almost made me give up on installing NLTK. Go to http://pypi.python.org/pypi/nltk and select nltk–3.2.5.win32.exe (md5). Download it. Once it’s downloaded, if you try to run the installer, you will get an error message like this:
- Do not worry! You have done nothing wrong, it is just a crappy installer so thanks very much to Google and Github I found out that everyone has this problem, not just me. So instead I used pip (a package management system used to install and manage Python software packages). So open up your command prompt which looks like this for those of you who, like me, weren’t 100% sure exactly what a command prompt was:
- Once that’s open, type in “py -m pip install nltk” (but not in quotation marks). If this doesn’t work for you and you definitely have Python 3.5.4 installed then you could try “python -m pip install nltk” as that works for some people. Also, don’t get impatient if nothing seems to show up at first. Wait until your C:\Users\YourUsername> bar pops up again. That means you can run a new command.
- Ok! Next, type in “py -m pip install –user numpy scipy matplotlib ipython jupyter pandas sympy nose” (or swap the py for python if the first option doesn’t work). This installs a whole bunch of libraries that will definitely be useful when using Python and NLTK. Just trust me on that one. (If you really want to, you can read more about these libraries here).
- Last but not least, this is an additional step that you might not even need to take but I did so I will tell you about it anyway. Don’t ask my why but the matplotlib library didn’t get installed properly so when I tried to use one of its functions it just didn’t work. So I entered “py -m pip install matplotlib” into the command prompt and it installed it.
- Hurrah you are done! Now open up your Python IDLE program and get started with the NLTK instruction book. Best of luck with your text mining!