我正在尝试在IBM Cloud / Bluemix上运行带有某些文本分析功能(使用TextBlob)的python flask应用程序。通过cf push命令部署该应用程序后,出现以下错误(请参见下文)。站点,当用户尝试使用需要用户在其系统上没有的数据集或模型的功能时,将引发此异常。
error:
Error while running the app:
textblob.exceptions.MissingCorpusError
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.
现在我的问题是我在我的require.txt文件中添加了Flask,Textblob和NLTK,如下所示。没有运行上面提到的命令,还有其他方法可以使这项工作吗? 注意:此应用程序可在本地系统上完美运行。
requirement.txt content:
Flask==0.12.2
cloudant==2.4.0
textblob==0.15.1
nltk==3.3
这是错误/警告,当我通过push命令部署应用程序时得到
-----> Downloading NLTK corpora...
! nltk.txt not found, not downloading any corpora
Henrik询问的编辑: 当我运行以下命令python -m textblob.download_corpora时,正在我的系统上下载corporas。我在nltk.txt文件中提到了相同的列表
`[nltk_data] Downloading package brown to
[nltk_data] C:\Users\MohanaKrishnaV\AppData\Roaming\nltk_data...
[nltk_data] Package brown is already up-to-date!
[nltk_data] Downloading package punkt to
[nltk_data] C:\Users\MohanaKrishnaV\AppData\Roaming\nltk_data...
[nltk_data] Package punkt is already up-to-date!
[nltk_data] Downloading package wordnet to
[nltk_data] C:\Users\MohanaKrishnaV\AppData\Roaming\nltk_data...
[nltk_data] Package wordnet is already up-to-date!
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data] C:\Users\MohanaKrishnaV\AppData\Roaming\nltk_data...
[nltk_data] Package averaged_perceptron_tagger is already up-to-
[nltk_data] date!
[nltk_data] Downloading package conll2000 to
[nltk_data] C:\Users\MohanaKrishnaV\AppData\Roaming\nltk_data...
[nltk_data] Package conll2000 is already up-to-date!
[nltk_data] Downloading package movie_reviews to
[nltk_data] C:\Users\MohanaKrishnaV\AppData\Roaming\nltk_data...
[nltk_data] Package movie_reviews is already up-to-date!
Finished.
这就是我的nltk.txt的样子
brown wordnet
averaged_perceptron_tagger
brown
sentence_polarity
sentiwordnet
subjectivity
words
punkt
maxent_treebank_pos_tagger
movie_reviews
conll2000
我在nltk.txt中添加了其他语料库,如下所示,希望没问题
sentence_polarity
sentiwordnet
subjectivity
words
这是错误日志的样子:
-------> Buildpack version 1.5.22
-----> Installing pip-pop (0.1.1)
Downloaded [https://buildpacks.cloudfoundry.org/dependencies/manual-
binaries/pip-pop/pip-pop-0.1.1-d410583a.tar.gz]
-----> Installing pipenv (4.0.1)
Downloaded [https://buildpacks.cloudfoundry.org/dependencies/manual-
binaries/pipenv/pipenv-4.0.1-148f753f.tar.gz]
$ pip install -r requirements.txt
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
-----> Downloading NLTK corpora...
-----> Downloading NLTK packages: brown wordnet
averaged_perceptron_tagger
brown
sentence_polarity
sentiwordnet
subjectivity
words
punkt
maxent_treebank_pos_tagger
movie_reviews
[nltk_data] Downloading package brown to
[nltk_data] /tmp/contents525031002/deps/0/python/nltk_data...
[nltk_data] Package brown is already up-to-date!
[nltk_data] Error loading wordnet : Package 'wordnet\r' not found in
[nltk_data] index
Error installing package. Retry? [n/y/e]
Traceback (most recent call last):
File "/tmp/contents525031002/deps/0/python/lib/python2.7/runpy.py", line
174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/tmp/contents525031002/deps/0/python/lib/python2.7/runpy.py", line
72, in _run_code
exec code in run_globals
File "/tmp/contents525031002/deps/0/python/lib/python2.7/site-
packages/nltk/downloader.py", line 2272, in <module>
halt_on_error=options.halt_on_error)
File "/tmp/contents525031002/deps/0/python/lib/python2.7/site-
packages/nltk/downloader.py", line 681, in download
choice = input().strip()
EOFError: EOF when reading a line
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (64.3M)
Uploaded droplet (105.6M)
Uploading complete
Stopping instance 6cbf3cbc-aef1-4a73-a7ab-d562a606fe5b
Destroying container
Successfully destroyed container
这是我推送应用程序的方式: cf login >> [我提供我的登录详细信息] >> cf push
答案 0 :(得分:0)
似乎您部署的应用程序的根目录中没有nltk.txt
。 The Cloud Foundry Python buildpacks have built-in support for NLTK。文本文件包含有关在部署过程中需要安装哪个语料库的信息。
nltk.txt
的内容示例:
wordnet averaged_perceptron_tagger brown sentence_polarity
确保它是一行,没有重复,也没有奇怪的字符...