chezobore
chezobore

Reputation: 51

Installing NLTK alongside EPD python in Ubuntu

I am a recent convert from Matlab/ Windows to Python/ Ubuntu. I have installed EPD python which is a python distribution that includes most scientific packages, I am super happy so far. Next, I needed to install NLTK to do some text analytics and followed the instructions on the nltk webpage. Problem is that all the packages (pyyaml,nltk etc) are getting installed into

/usr/local/lib/python2.7

However, I already changed my .bashrc (as specifed in post-installations instructions of EPD) and added the following line at the end of it.

export PATH=/home/myname/epd/bin:$PATH

and sys.path from my python shell returns

['',
 '/home/myname/epd/bin',
 '/home/myname/epd/lib/python2.7/site-packages/pandas-0.10.0-py2.7-  linux-i686.egg',
 '/home/myname/epd/lib/python27.zip',
 '/home/myname/epd/lib/python2.7',
 '/home/myname/epd/lib/python2.7/plat-linux2',
 '/home/myname/epd/lib/python2.7/lib-tk',
 '/home/myname/epd/lib/python2.7/lib-old',
 '/home/myname/epd/lib/python2.7/lib-dynload',
 '/home/myname/epd/lib/python2.7/site-packages',
 '/home/myname/epd/lib/python2.7/site-packages/PIL',
 '/home/myname/epd/lib/python2.7/site-packages/IPython/extensions']

Any help regarding how to make new python packages install into the right path is much appreciated. If you have time, please do elaborate on why this is happening and what I am doing wrong. Thanks a ton for you time!

Upvotes: 5

Views: 937

Answers (3)

PythonJin
PythonJin

Reputation: 4134

I recently installed NLTK and PyYAML because I'm working through "Natural Language Processing with Python". I was pleasantly surprised to find that both are available through the EPD package manager enpkg (although NLTK isn't listed on the Enthought site as being available).

$ enpkg -s pyyaml
Name                   Versions           Note
------------------------------------------------------------
PyYAML                 3.9-2              
                       3.10-1      

$ enpkg -s nltk
Name                   Versions           Note
------------------------------------------------------------
nltk                   2.0.1rc1-1         
                       2.0.1rc1-2         
                       2.0.1-1 

You can install both using:

$ enpkg pyyaml
$ enpkg nltk

and you're good to go!

Upvotes: 1

alvas
alvas

Reputation: 122168

For scientific python modules in NLTK, normally scipy would have suffice basic scientific functions and numpy would have covered the statistics. The NLTK installation site strongly recommends pip too. http://nltk.org/install.html

  1. Open Finder>Applications>Utilities>Terminal and type python -V to find out what version of Python is installed

  2. Install Setuptools: Download the corresponding version of Setuptools from http://pypi.python.org/pypi/setuptools (scroll to the bottom, and pick the filename that contains the right version number and which has the extension .egg). Install it by typing sudo sh Downloads/setuptools-...egg, giving the location of the downloaded file.

  3. Install Pip: run sudo easy_install pip

  4. Install Numpy (optional): run sudo pip install -U numpy

  5. Install PyYAML and NLTK: run sudo pip install -U pyyaml nltk

  6. Test installation: run python then type import nltk

Upvotes: 0

flup
flup

Reputation: 27104

You have two good choices for setting up your python environment in ubuntu:

  1. Use the ubuntu packages, like Thorsten suggests.

  2. Use the pip package manager in a virtualenv. This way you can set up multiple environments and hop from one to the other. A virtualenv can be configured to also include the system-wide ubuntu packages.

    nltk exists as a pip package: http://pypi.python.org/pypi/nltk/2.0.4

    pip has some trouble on ubuntu when linking to c libraries, since ubuntu places them in a place where the setup scripts do not look. Make sure to also install the -dev version of the dependency packages, since they contain the header files that pip needs, and copy or link the libraries from /usr/lib/your linux architecture/lib/ to /usr/local/lib so that pip may find them.

Upvotes: 1

Related Questions