如何解决导入包 "ltk "后,但在执行 "ltk.downloader "之前,在sys.modules中发现的RuntimeWarning:"ltk.downloader"?

问题描述 投票:0回答:1
-----> Python app detected
-----> No change in requirements detected, installing from cache
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Downloading NLTK corpora…
-----> Downloading NLTK packages: wordnet
/app/.heroku/python/lib/python3.6/runpy.py:125: RuntimeWarning: 'nltk.downloader' found in sys.modules after import of package 'nltk', but prior to execution of 'nltk.downloader'; this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
[nltk_data] Downloading package wordnet to /tmp/build_258085236d56e3b4
[nltk_data]     5c3f16d4bfeb1865/.heroku/python/nltk_data...
 [nltk_data]   Unzipping corpora/wordnet.zip.

.....
   Released v8

   https://cov-19dashboard.herokuapp.com/ deployed to Heroku

当我试图在Heroku上部署一个应用程序时,我一直收到这个Runtime错误。

我试着替换了

if __name__ == '__main__':
    app.run_server(debug=True)

在主应用程序文件(app.py)上用

if __name__ == "__main__":
    import warnings
    warnings.warn("use 'python -m nltk', not 'python -m nltk.downloader'",         DeprecationWarning)
    app.run_server(debug=True)

但我仍然得到了警告,这是在Heroku服务器上阻止dash应用程序的正确显示。

如果有任何帮助,我将感激不尽

python heroku runtime-error nltk dashboard
1个回答
0
投票

部署过程失败的问题可能不是你上面提到的警告。要想知道在部署过程中到底遇到了哪些失败的步骤,你必须调查日志文件,方法是点开 $ heroku logs --tail 关于nltk包,如果你用windows编辑你的应用程序文件,确保在你的终端上的 nltk.txt 文件被转换为unix结尾,以便成功地下载你需要的文件。例如,你需要下载 stopwordspunkt 包,编辑 nltk.txt 这样的文件。

stopwords

punkt

最重要的是要用命令来调查日志 heroku logs 而不是仅仅从终端读取 heroku 仪表板上的 Build Log。后者并不能给你提供部署失败的根本原因。

© www.soinside.com 2019 - 2024. All rights reserved.