RE: error problems for import some copora with nltk

Discussion in 'Python' started by Tony Meyer, Dec 22, 2004.

  1. Tony Meyer

    Tony Meyer Guest

    > I am trying to follow the tutorial, but I kept getting error messages
    > about importing corpus as follows
    >
    > ===================================================
    > >>> from nltk.corpus import gutenberg

    >
    > Traceback (most recent call last):
    > File "<pyshell#3>", line 1, in -toplevel-
    > from nltk.corpus import gutenberg
    > ImportError: cannot import name gutenberg
    > ===================================================
    >
    > I got the data files under c:\\python24\nltk\


    Have you imported nltk before that line? Try this:

    Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import nltk
    >>> from nltk.corpus import gutenberg


    I suspect you may be doing this:

    Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from nltk.corpus import gutenburg

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ImportError: cannot import name gutenburg

    Note that if the corpus can't be found, you can still do the import (just
    not use the corpus).

    =Tony.Meyer
    Tony Meyer, Dec 22, 2004
    #1
    1. Advertising

  2. Tony Meyer

    Guest

    Dear Tony.Meyer,

    Thank you for answering this. I did exactly what you told me, but I got
    following messages.
    Do you have any idea?

    =============================================================================
    >>> import nltk
    >>> from nltk.corpus import gutenberg


    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in -toplevel-
    from nltk.corpus import gutenberg
    File "C:\Python23\lib\site-packages\nltk\corpus\__init__.py", line
    134, in -toplevel-
    from nltk.tokenreader import *
    File "C:\Python23\lib\site-packages\nltk\tokenreader\__init__.py",
    line 57, in -toplevel-
    from nltk.tokenreader.treebank import *
    File "C:\Python23\lib\site-packages\nltk\tokenreader\treebank.py",
    line 15, in -toplevel-
    from nltk.tokenreader.tagged import ChunkedTaggedTokenReader
    File "C:\Python23\lib\site-packages\nltk\tokenreader\tagged.py", line
    15, in -toplevel-
    from nltk.tree import Tree
    File "C:\Python23\lib\site-packages\nltk\tree.py", line 33, in
    -toplevel-
    from nltk.probability import ProbabilisticMixIn,
    ImmutableProbabilisticMixIn
    File "C:\Python23\lib\site-packages\nltk\probability.py", line 56, in
    -toplevel-
    import types, math, Numeric
    ImportError: No module named Numeric
    ================================================================================
    Thanks gain,

    Kyung in Texas,
    , Dec 22, 2004
    #2
    1. Advertising

  3. <> wrote:

    > Thank you for answering this. I did exactly what you told me, but I got
    > following messages.
    >
    > Do you have any idea?


    > ImportError: No module named Numeric


    have you installed the Numeric library? see the NLTK download page for
    details:

    http://nltk.sourceforge.net/install.html

    </F>
    Fredrik Lundh, Dec 22, 2004
    #3
  4. Tony Meyer

    Jeff Shannon Guest

    wrote:

    >Dear Tony.Meyer,
    >
    >Thank you for answering this. I did exactly what you told me, but I got
    >following messages.
    >Do you have any idea?
    >
    >=============================================================================
    >
    >
    >>>>import nltk
    >>>>from nltk.corpus import gutenberg
    >>>>
    >>>>

    >
    >Traceback (most recent call last):
    >[...]
    >import types, math, Numeric
    >ImportError: No module named Numeric
    >
    >


    At a guess, the nltk package is dependent upon Numeric already being
    installed, and you don't have Numeric. Check your nltk documentation to
    see if there's particular versions of Numeric that are required, and
    then ensure that you have (or get) an appropriate version.

    Jeff Shannon
    Technician/Programmer
    Credit International
    Jeff Shannon, Dec 22, 2004
    #4
  5. Tony Meyer

    Guest

    Hi,

    According to your advice, I installed the numeric library which is
    numarray-1.1.1.win32-py2.4.exe, but I got the error message as follows.
    Any help? frustrated...
    ================================================================
    >>> from nltk.corpus import gutenberg


    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in -toplevel-
    from nltk.corpus import gutenberg
    File "C:\Python24\Lib\site-packages\nltk\corpus\__init__.py", line
    134, in -toplevel-
    from nltk.tokenreader import *
    File "C:\Python24\Lib\site-packages\nltk\tokenreader\__init__.py",
    line 57, in -toplevel-
    from nltk.tokenreader.treebank import *
    File "C:\Python24\Lib\site-packages\nltk\tokenreader\treebank.py",
    line 15, in -toplevel-
    from nltk.tokenreader.tagged import ChunkedTaggedTokenReader
    File "C:\Python24\Lib\site-packages\nltk\tokenreader\tagged.py", line
    15, in -toplevel-
    from nltk.tree import Tree
    File "C:\Python24\Lib\site-packages\nltk\tree.py", line 33, in
    -toplevel-
    from nltk.probability import ProbabilisticMixIn,
    ImmutableProbabilisticMixIn
    File "C:\Python24\Lib\site-packages\nltk\probability.py", line 56, in
    -toplevel-
    import types, math, Numeric
    ImportError: No module named Numeric
    ================================================================

    Kyung
    , Dec 23, 2004
    #5
  6. Tony Meyer

    Jeff Shannon Guest

    wrote:

    >Hi,
    >
    >According to your advice, I installed the numeric library which is
    >numarray-1.1.1.win32-py2.4.exe, but I got the error message as follows.
    >Any help? frustrated...
    >================================================================
    >
    >
    >>>>from nltk.corpus import gutenberg
    >>>>
    >>>>

    >
    >[...]
    >import types, math, Numeric
    >ImportError: No module named Numeric
    >
    >


    Numarray is not Numeric. You need to install Numeric, because NLTK
    doesn't use numarray. (As I understand it, numarray is intended as a
    replacement for Numeric, but modules/packages must be recoded to use it
    -- it doesn't happen automatically.)

    Jeff Shannon
    Technician/Programmer
    Credit International
    Jeff Shannon, Dec 23, 2004
    #6
  7. Tony Meyer

    Guest

    Dear Jeff,

    Thank you, it was the numeric. After I installed the numeric library
    which is Numeric-23.6.win32-py2.3.exe for python 2.3.4 verson, it is
    working correctly.

    Thank you again,

    Kyung
    , Dec 23, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. j_pennington_moore

    newbie NLTK question

    j_pennington_moore, Jul 20, 2004, in forum: Python
    Replies:
    0
    Views:
    313
    j_pennington_moore
    Jul 20, 2004
  2. Replies:
    1
    Views:
    282
    Fredrik Lundh
    Dec 22, 2004
  3. Passer By

    NLTK, Random Sentence Generators?

    Passer By, Apr 10, 2007, in forum: Python
    Replies:
    8
    Views:
    1,920
    Oleg Alexander
    Apr 12, 2007
  4. Steven Bird
    Replies:
    1
    Views:
    386
    tool69
    May 26, 2007
  5. Error in Python NLTK

    , Apr 6, 2013, in forum: Python
    Replies:
    8
    Views:
    174
    Steven D'Aprano
    Apr 7, 2013
Loading...

Share This Page