nltk/nltk — Issue #98: easy_install nltk 2.0b8 fails, ImportError: No module named yaml
Author: alexrudnick
Created: 2012-01-17 06:26:02+00:00
State: open

macmini01:zeocluster centrimadmin$ ../Python-2.4/bin/python -V
Python 2.4.6

macmini01:zeocluster centrimadmin$ pwd
/Applications/Plone/zeocluster

sudo ../Python-2.4/bin/easy_install -N nltk
fails,

ImportError: No module named yaml

Details to follow.

Migrated from http://code.google.com/p/nltk/issues/detail?id=508

earlier comments

grahamperrin said, at 2010-02-05T21:35:24.000Z:

result of
sudo ../Python-2.4/bin/easy_install -N nltk

grahamperrin said, at 2010-02-05T21:36:59.000Z:

tail of result of
sudo bin/buildout -n -t 30 -vv -c omnium-macmini01.cfg

grahamperrin said, at 2010-02-05T21:37:22.000Z:

macmini01:zeocluster centrimadmin$ ../Python-2.4/bin/easy_install --version
distribute 0.6.10

bowlesling said, at 2010-03-24T01:35:41.000Z:

Same thing here. I've installed nltk on a Windows Vista (no problems), Ubuntu 9.04
(no problems), Fedora 12 (slight problems); and now on a brand new install of Arch
Linux (using KDE4.4 as the desktop). Here is what I get:
==================================
Traceback (most recent call last):
File "setup.py", line 13, in
import nltk
File "/home/josh/nltk-2.0b8/nltk-2.0b8/nltk/__init__.py", line 92, in
from yamltags import *
File "/home/josh/nltk-2.0b8/nltk-2.0b8/nltk/yamltags.py", line 1, in
import yaml
=============================
I tried fresh download but same thing.

bowlesling said, at 2010-03-24T01:50:43.000Z:

I installed PyYAML (3.09) separately (got it from here http://pyyaml.org/wiki/PyYAML),
and then ran the setup.py in nltk-2.0b8, it has installed... I have to checked it
out... is there any reason why this shouldn't work... or why it might be a problem?

i.am.alex.too said, at 2010-06-30T19:02:27.000Z:

The problem is that setup.py import nltk and nltk/__init__.py import yamltags which imports yaml. If yaml is not installed prior nltk installation, it crashes.

dimazest said, at 2011-07-05T20:40:35.000Z:

This patch http://paste.pocoo.org/show/430395/ eliminates import of nltk in setup-*.py.

Instead all the release information is stored in nltk.release and it is imported by nltk/__init__.py. setup.py runs execfile() to get the release data.

kmike84 said, at 2011-07-13T22:37:20.000Z:

+1 for the patch because depending on yaml in setup.py breaks installation from pip requirements file.

pip installs packages in 3 steps:

a) it downloads them;
b) runs ./setup.py egg_info for each package;
c) actually installs them.

So even if PyYAML is in requirements installation will fail because PyYAML won't be installed yet at the point (b) and nltk wants yaml in setup.py.

Installer shouldn't require dependency to be installed because in order to know what are the dependencies the installer should be executed itself.

dimazest said, at 2011-07-14T14:55:29.000Z:

Actually, I've forgotten to include nltk/release.py :( Thought, its contents is just a copied from the nltk/__init__.py

lance@lrvick.net said, at 2011-09-20T22:58:24.000Z:

This is still an issue.

A setup.py should /never/ import anything that does not ship with python, ergo importing a package that may or may not exist. Any system or virtualenv that does not _already_ have yaml installed, fails as soon as pip trys to run the setup.py and an end developer is left wondering what to do. I myself have had to waste hours figuring this out.

Please rework this so this import is not required. Most systems do not ship with pyyaml by default, and it makes it really hard for us to include nltk as a dependency of our own packages.

Please fix. :-(