首页 > 解决方案 > 在heroku上安装nltk包时出错

问题描述

我正在尝试使用 nltk.txt 文件在 heroku 中安装 nltk 包。在我的 nltk.txt 文件中只写入了 punkt。在 requirements.txt 文件中写入了 nltk。但是当推动它时,它会显示错误。请帮助解决我的问题

remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.6.7
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing requirements with pip
remote:
remote: -----> Downloading NLTK corpora…
remote: -----> Downloading NLTK packages: tokenize
remote: /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
remote:   warn(RuntimeWarning(msg))
remote: Traceback (most recent call last):
remote:        [nltk_data] Error loading tokenize : Package 'tokenize ' not found in
remote:   File "/app/.heroku/python/lib/python3.6/runpy.py", line 193, in _run_module_as_main
remote:        [nltk_data]     index
remote:     "__main__", mod_spec)
remote:   File "/app/.heroku/python/lib/python3.6/runpy.py", line 85, in _run_code
remote:     exec(code, run_globals)
remote:   File "/app/.heroku/python/lib/python3.6/site-packages/nltk/downloader.py", line 2272, in <module>
remote:        Error installing package. Retry? [n/y/e]
remote:     halt_on_error=options.halt_on_error)
remote:   File "/app/.heroku/python/lib/python3.6/site-packages/nltk/downloader.py", line 681, in download
remote:     choice = input().strip()
remote: EOFError: EOF when reading a line
remote: -----> Running post-compile hook
remote: -----> Running install_nltk_data
remote: -----> Starting nltk data installation
remote: /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
remote:   warn(RuntimeWarning(msg))
remote: [nltk_data] Downloading package punkt to /app/nltk_data...
remote: [nltk_data]   Unzipping tokenizers/punkt.zip.
remote: bin/install_nltk_data: line 21: cd: '/app/nltk_data': No such file or directory
remote: -----> Finished nltk data installation
remote: -----> Post-compile done
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 49M
remote: -----> Launching...
remote:        Released v19
remote:        https://mysterious-coast-63128.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/mysterious-coast-63128.git
   7b1a415..9b14971  master -

标签: pythonflaskherokunltknltk-trainer

解决方案


推荐阅读