Ubuntu-12.04 [SOLVED]: How to get TextBlob to work with all users on Ubuntu?

Ubuntu-12.04 [SOLVED]: How to get TextBlob to work with all users on Ubuntu?

Home Forums Ubuntu 12.04 Ubuntu-12.04 [SOLVED]: How to get TextBlob to work with all users on Ubuntu?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #16626

    Anonymous

    QuestionQuestion

    I’m trying to get TextBlob up and running for some teammates on a Unix server, it appears to be working just fine when I run scripts that make use of TextBlob when running as root, however when I try on the new account I create I get the following error:

    **********************************************************************
      Resource u'tokenizers/punkt/english.pickle' not found.  Please
      use the NLTK Downloader to obtain the resource:  >>>
      nltk.download()
      Searched in:
        - '/home/USERNAME/nltk_data'
        - '/usr/share/nltk_data'
        - '/usr/local/share/nltk_data'
        - '/usr/lib/nltk_data'
        - '/usr/local/lib/nltk_data'
        - u''
    **********************************************************************
    Traceback (most recent call last):
      File "sampleClassifier.py", line 25, in <module>
        cl = NaiveBayesClassifier(train)
      File "/usr/local/lib/python2.7/dist-packages/textblob/classifiers.py", line 192, in __init__
        self.train_features = [(self.extract_features(d), c) for d, c in self.train_set]
      File "/usr/local/lib/python2.7/dist-packages/textblob/classifiers.py", line 169, in extract_features
        return self.feature_extractor(text, self.train_set)
      File "/usr/local/lib/python2.7/dist-packages/textblob/classifiers.py", line 81, in basic_extractor
        word_features = _get_words_from_dataset(train_set)
      File "/usr/local/lib/python2.7/dist-packages/textblob/classifiers.py", line 63, in _get_words_from_dataset
        return set(all_words)
      File "/usr/local/lib/python2.7/dist-packages/textblob/classifiers.py", line 62, in <genexpr>
        all_words = chain.from_iterable(tokenize(words) for words, _ in dataset)
      File "/usr/local/lib/python2.7/dist-packages/textblob/classifiers.py", line 59, in tokenize
        return word_tokenize(words, include_punc=False)
      File "/usr/local/lib/python2.7/dist-packages/textblob/tokenizers.py", line 72, in word_tokenize
        for sentence in sent_tokenize(text))
      File "/usr/local/lib/python2.7/dist-packages/textblob/base.py", line 64, in itokenize
        return (t for t in self.tokenize(text, *args, **kwargs))
      File "/usr/local/lib/python2.7/dist-packages/textblob/decorators.py", line 38, in decorated
        raise MissingCorpusError()
    textblob.exceptions.MissingCorpusError:
    Looks like you are missing some required data for this feature.
    
    To download the necessary data, simply run
    
        python -m textblob.download_corpora
    
    or use the NLTK downloader to download the missing data: http://nltk.org/data.html
    If this doesn't fix the problem, file an issue at https://github.com/sloria/TextBlob/issues.
    

    The machine we’re working with is very small so I can’t overwhelm it by downloading the corpora several times for different users – does anyone know how I might fix this issue? I already have it installed for root, but I don’t know where the packages are or how to find them.

    #16627

    Anonymous

    Accepted AnswerAnswer

    Following the instructions in the docs should work. Try setting NLTK_DATA environment variable and see if it works for the new user.

    Source: https://stackoverflow.com/questions/43864281/how-to-get-textblob-to-work-with-all-users-on-ubuntu
    Author: Rubbal
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.