Celery引发了意外的LookUp错误

时间:2016-04-20 09:43:18

标签: django celery nltk java-home pos-tagger

我正在为我的django项目使用芹菜。

java_path = "/your/Java/jdk/home/java.exe
os.environ['JAVAHOME'] = java_path

st = POSTagger('/your/postagger/models/path/english-bidirectional-distsim.tagger','/your/postagger/jar/file/path/stanford-postagger.jar')

tag = st.tag([key])

这里的关键是一个特征词列表。

使用芹菜执行时出现以下错误:

raised unexpected: 
           LookupError('\n\n===========================================================================\nNLTK 
        `was unable to find the java file!\nUse software specific configuration paramaters or set the JAVAHOME environment`



variable.\n===========================================================================',)
        Traceback (most recent call last):
          File "/Users/Envs/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
            R = retval = fun(*args, **kwargs)
          File "/Users/Envs/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
            return self.run(*args, **kwargs)
          File "/Users/Envs/src/evolvelearning/tasks.py", line 772, in RunProgram
            tag = st.tag([key])
          File "/Users/Envs/lib/python2.7/site-packages/nltk/tag/stanford.py", line 59, in tag
            return self.tag_sents([tokens])[0]
        File "/Users/Envs/lib/python2.7/site-packages/nltk/tag/stanford.py", line 64, in tag_sents
        config_java(options=self.java_options, verbose=False)
      File "/Users/Envs/lib/python2.7/site-packages/nltk/internals.py", line 82, in config_java
        _java_bin = find_binary('java', bin, env_vars=['JAVAHOME', 'JAVA_HOME'], verbose=verbose, binary_names=['java.exe'])


        File "/Users/Envs/lib/python2.7/site-packages/nltk/internals.py", line 544, in find_binary
            binary_names, url, verbose))
          File "/Users/Envs/lib/python2.7/site-packages/nltk/internals.py", line 538, in find_binary_iter
            url, verbose):
          File "/Users/Envs/lib/python2.7/site-packages/nltk/internals.py", line 517, in find_file_iter
            raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
        LookupError:

        ===========================================================================
    NLTK was unable to find the java file!
    Use software specific configuration paramaters or set the JAVAHOME environment variable.
    ===========================================================================

我设置了 java_path javahome ,我想知道为什么还会发生错误?

1 个答案:

答案 0 :(得分:0)

我的环境是MAC。

问题是java_path,应该是:

java_path = "/your/Java/jdk/home