Python IBM cloud/bluemix 上的 Flask 应用程序带有 Textblob 库抛出异常 - textblob.exceptions.MissingCorpusError
Python Flask Application on IBM cloud/bluemix with Textblob library throwing exception - textblob.exceptions.MissingCorpusError
我正在尝试 运行 python Flask 应用程序在 IBM cloud/Bluemix 上使用一些文本分析(使用 TextBlob)功能。通过 cf 部署应用程序后我收到以下错误push 命令(见下文)。根据 TextBlob 网站上的文档,当用户尝试使用需要用户系统上没有的数据集或模型的功能时,会抛出此异常。
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.
现在我的问题是我已经在 requirement.txt 中添加了 Flask、Textblob 和 NLTK,如图所示 below.Please 建议如何 运行 python -m textblob.download_corpora 命令使这个缺失的 dataset/model 可用于 bluemix environment.If 而不是上面提到的 运行ning 命令,有没有其他方法可以使它工作。
Note:This 应用程序在本地系统上运行完美。
requirement.txt content:
Flask==0.12.2
cloudant==2.4.0
textblob==0.15.1
nltk==3.3
这是 error/warning 我在通过推送命令部署应用程序时得到的
-----> Downloading NLTK corpora...
! nltk.txt not found, not downloading any corpora
Henrik 询问的编辑:
当我 运行 命令 python -m textblob.download_corpora 下面的语料库正在下载到我的 system.I 时,我在 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
您部署的应用程序的根目录中似乎没有 nltk.txt
。 The Cloud Foundry Python buildpacks have built-in support for NLTK。该文本文件包含有关在部署期间需要安装哪些语料库的信息。
nltk.txt
的示例内容:
wordnet averaged_perceptron_tagger brown sentence_polarity
确保它是单行的,没有重复的,没有奇怪的字符...
我正在尝试 运行 python Flask 应用程序在 IBM cloud/Bluemix 上使用一些文本分析(使用 TextBlob)功能。通过 cf 部署应用程序后我收到以下错误push 命令(见下文)。根据 TextBlob 网站上的文档,当用户尝试使用需要用户系统上没有的数据集或模型的功能时,会抛出此异常。
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.
现在我的问题是我已经在 requirement.txt 中添加了 Flask、Textblob 和 NLTK,如图所示 below.Please 建议如何 运行 python -m textblob.download_corpora 命令使这个缺失的 dataset/model 可用于 bluemix environment.If 而不是上面提到的 运行ning 命令,有没有其他方法可以使它工作。 Note:This 应用程序在本地系统上运行完美。
requirement.txt content:
Flask==0.12.2
cloudant==2.4.0
textblob==0.15.1
nltk==3.3
这是 error/warning 我在通过推送命令部署应用程序时得到的
-----> Downloading NLTK corpora...
! nltk.txt not found, not downloading any corpora
Henrik 询问的编辑: 当我 运行 命令 python -m textblob.download_corpora 下面的语料库正在下载到我的 system.I 时,我在 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
您部署的应用程序的根目录中似乎没有 nltk.txt
。 The Cloud Foundry Python buildpacks have built-in support for NLTK。该文本文件包含有关在部署期间需要安装哪些语料库的信息。
nltk.txt
的示例内容:
wordnet averaged_perceptron_tagger brown sentence_polarity
确保它是单行的,没有重复的,没有奇怪的字符...