Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 360
chezobore Avatar asked Nov 03 '22 06:11

chezobore


1 Answers

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.

like image 186
flup Avatar answered Nov 09 '22 10:11

flup