Finding out which NLTK version is installed

3,801 views
Skip to first unread message

josep_m

unread,
Jul 29, 2010, 6:14:15 AM7/29/10
to nltk-users
This is a very stupid question but I've tried to find the answer in
the documentation and googling to no avail. How do I know what version
of NLTK am I runnin? I'm using a laptop where I had installed NLTK
quite a long time ago. I wanted to upgrade to the latest version of
NLTK but first I wanted to know which version I currently have to
determine whether it is really worthwhile to do an upgrade.

Things get even complicated because I upgraded my version of Ubuntu to
10.4. After reading that now NLTK comes with Lucid and without giving
it too much thought, I did "apt-get install python-nltk" and
apparently some kind of installation took place. The thing is, after
doing that, I remembered I had already installed NLTK before so now I
don't know which version of NLTK I am actually using when I do 'import
nltk' from within python.

Thanks in advance for your help.


JMF

Tim McNamara

unread,
Jul 29, 2010, 6:18:18 AM7/29/10
to nltk-...@googlegroups.com
On Thu, Jul 29, 2010 at 10:14 PM, josep_m <josep.m...@gmail.com> wrote:
This is a very stupid question but I've tried to find the answer in
the documentation and googling to no avail. How do I know what version
of NLTK am I runnin? I'm using a laptop where I had installed NLTK
quite a long time ago. I wanted to upgrade to the latest version of
NLTK but first I wanted to know which version I currently have to
determine whether it is really worthwhile to do an upgrade.

>>> import nltk
>>> nltk.__version__
'2.0b8'
 

josep_m

unread,
Jul 29, 2010, 12:58:43 PM7/29/10
to nltk-users
OK, thanks a lot Tim. Oops, this should have been easy to figure out
since it is general Python knowledge.

So, I see the version I have running is 2.0b6. This even after having
done an 'apt-get install python-nltk'. So this is what I feared. The
version I installed via apt-get is 2.0b8. I guess I just have to
uninstall the old version and add the appropriate paths to the
environment variables, right?

JM



On Jul 29, 12:18 pm, Tim McNamara <mcnamara....@gmail.com> wrote:

Tim McNamara

unread,
Jul 29, 2010, 6:39:41 PM7/29/10
to nltk-...@googlegroups.com
On Fri, Jul 30, 2010 at 4:58 AM, josep_m <josep.m...@gmail.com> wrote:
OK, thanks a lot Tim. Oops, this should have been easy to figure out
since it is general Python knowledge.

No problem at all! Questions like this are easy to answer :)
 
So, I see the version I have running is 2.0b6. This even after having
done an 'apt-get install python-nltk'. So this is what I feared. The
version I installed via apt-get is 2.0b8. I guess I just have to
uninstall the old version and add the appropriate paths to the
environment variables, right?

JM

No need to fear. Short answer:

$ sudo apt-get install python-setuptools  # install easy_install & other goodies
$ sudo easy_install -U nltk # "-U" stands for upgrade

Long answer:

Python doesn't really support install/uninstall. It's a bit of a fallacy. Python has something closer to found/not found. This means that if there is a package on the Python path, then it is "installed". In Linux, install/uninstall can be as simple as creating and removing a symbolic links. 

By convention, Linux distributions hold version numbers of packages in their archives fixed unless there are stability or security concerns.* AFAIK Debian holds this policy very strong, and will only provide security updates for packages, which means the version available via apt-get is often out of date. Ubuntu is basically Debian unstable, which means that few Ubuntu ppackages are not updated. Therefore, Lucid Lynx had NLTK version 2.08b at "package freeze", it will never upgrade.

The advantage of keeping version numbers fixed is stability. Fixes can be worked on if new features are not being worked on. This is why you will hear the term "package maintainer" used in the Linux world. Their job is to make the system more secure, but not build new features. However, when you want the latest software - you need to retrieve it from source. 

In terms of Python, there are two tools that make this very easy: easy_install & pip. Pip is better, because it supports virtual Python environments.    It also supports downloaded the latest sources from svn, hg, git & bzr, rather than relying on what is currently in Python. However, I haven't been able to install NLTK via pip and it's not really necessary, so haven't given you those instructions. Virtual environments make things easier for software developers that will be moving their work to a server somewhere. They replicate what it's like to be in a completely new computer. For people using NLTK, that's not really important.

There's a lot of assumed knowledge in that long answer. I hope it's comprehensible. If you would like any more information, do ask.

Tim.
* There are alternatives. If you would like a Linux distro that has a continually rolling release cycle for all of its packages, consider Arch Linux.
Reply all
Reply to author
Forward
0 new messages