gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.08k stars 4.44k forks source link

Flask app using ChatterBot #645

Closed a-elhaddad closed 7 years ago

a-elhaddad commented 7 years ago

# have created a simple Flask app using ChatterBot with Heroku but 👍: 2017-03-03T09:29:05.195670+00:00 app[web.1]: Traceback (most recent call last): 2017-03-03T09:29:05.195672+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker 2017-03-03T09:29:05.195673+00:00 app[web.1]: worker.init_process() 2017-03-03T09:29:05.195675+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process 2017-03-03T09:29:05.195675+00:00 app[web.1]: self.load_wsgi() 2017-03-03T09:29:05.195676+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi 2017-03-03T09:29:05.195676+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2017-03-03T09:29:05.195678+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi 2017-03-03T09:29:05.195678+00:00 app[web.1]: self.callable = self.load() 2017-03-03T09:29:05.195679+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 2017-03-03T09:29:05.195680+00:00 app[web.1]: return self.load_wsgiapp() 2017-03-03T09:29:05.195681+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 2017-03-03T09:29:05.195681+00:00 app[web.1]: return util.import_app(self.app_uri) 2017-03-03T09:29:05.195682+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 357, in import_app 2017-03-03T09:29:05.195683+00:00 app[web.1]: __import__(module) 2017-03-03T09:29:05.195684+00:00 app[web.1]: File "/app/app_me.py", line 7, in <module> 2017-03-03T09:29:05.195687+00:00 app[web.1]: english_bot = ChatBot("English Bot") 2017-03-03T09:29:05.195688+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/chatterbot/chatterbot.py", line 83, in __init__ 2017-03-03T09:29:05.195688+00:00 app[web.1]: self.initialize() 2017-03-03T09:29:05.195689+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/chatterbot/chatterbot.py", line 93, in initialize 2017-03-03T09:29:05.195690+00:00 app[web.1]: nltk_download_corpus('corpora/wordnet') 2017-03-03T09:29:05.195690+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/chatterbot/utils.py", line 118, in nltk_download_corpus 2017-03-03T09:29:05.195691+00:00 app[web.1]: find(resource_path) 2017-03-03T09:29:05.195692+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/nltk/data.py", line 635, in find 2017-03-03T09:29:05.195692+00:00 app[web.1]: return find(modified_name, paths) 2017-03-03T09:29:05.195693+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/nltk/data.py", line 621, in find 2017-03-03T09:29:05.195694+00:00 app[web.1]: return ZipFilePathPointer(p, zipentry) 2017-03-03T09:29:05.195695+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/nltk/compat.py", line 366, in _decorator 2017-03-03T09:29:05.195695+00:00 app[web.1]: return init_func(*args, **kwargs) 2017-03-03T09:29:05.195696+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/nltk/data.py", line 470, in __init__ 2017-03-03T09:29:05.195697+00:00 app[web.1]: zipfile = OpenOnDemandZipFile(os.path.abspath(zipfile)) 2017-03-03T09:29:05.195697+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/nltk/compat.py", line 366, in _decorator 2017-03-03T09:29:05.195698+00:00 app[web.1]: return init_func(*args, **kwargs) 2017-03-03T09:29:05.195699+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/nltk/data.py", line 986, in __init__ 2017-03-03T09:29:05.195699+00:00 app[web.1]: zipfile.ZipFile.__init__(self, filename) 2017-03-03T09:29:05.195700+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/zipfile.py", line 1100, in __init__ 2017-03-03T09:29:05.195701+00:00 app[web.1]: self._RealGetContents() 2017-03-03T09:29:05.195701+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/zipfile.py", line 1167, in _RealGetContents 2017-03-03T09:29:05.195702+00:00 app[web.1]: raise BadZipFile("File is not a zip file") 2017-03-03T09:29:05.195702+00:00 app[web.1]: zipfile.BadZipFile: File is not a zip file 2017-03-03T09:29:05.195985+00:00 app[web.1]: [2017-03-03 09:29:05 +0000] [9] [INFO] Worker exiting (pid: 9) 2017-03-03T09:29:05.338455+00:00 app[web.1]: [nltk_data] Unzipping corpora/wordnet.zip. 2017-03-03T09:29:05.802331+00:00 app[web.1]: [nltk_data] Downloading package punkt to /app/nltk_data... 2017-03-03T09:29:06.093500+00:00 app[web.1]: [nltk_data] Unzipping tokenizers/punkt.zip. 2017-03-03T09:29:06.598217+00:00 app[web.1]: [nltk_data] Downloading package vader_lexicon to /app/nltk_data... 2017-03-03T09:29:06.613188+00:00 app[web.1]: [2017-03-03 09:29:06 +0000] [8] [INFO] Worker exiting (pid: 8) 2017-03-03T09:29:06.752578+00:00 app[web.1]: [2017-03-03 09:29:06 +0000] [4] [INFO] Shutting down: Master 2017-03-03T09:29:06.752664+00:00 app[web.1]: [2017-03-03 09:29:06 +0000] [4] [INFO] Reason: Worker failed to boot. 2017-03-03T09:29:06.866228+00:00 heroku[web.1]: State changed from up to crashed 2017-03-03T09:29:06.822642+00:00 heroku[web.1]: Process exited with status 3

gunthercox commented 7 years ago

Hi @addelll, I based on the stack trace I can't pinpoint the exact cause of your failed Heroku deployment. What parameters are you passing to the ChatBot class in your code?

a-elhaddad commented 7 years ago

the simple example didn't work with flask in heroku , i tested the example https://github.com/chamkank/flask-chatterbot

from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer from langdetect import detect_langs from time import sleep import json from chatterbot.conversation.session import ConversationSessionManager import uuid

chatbot = ChatBot("Adddell", silence_performance_warning=False)

chatbot.set_trainer(ChatterBotCorpusTrainer) chatbot.train("chatterbot.corpus.french") chatbot.train( "chatterbot.corpus.french.greetings", "chatterbot.corpus.french.trivia", )

gunthercox commented 7 years ago

Are you able to run @chamkank's flask app example locally without error?

a-elhaddad commented 7 years ago

yes it's working localy

a-elhaddad commented 7 years ago

hi just tell me best config (python version and requirements) that should i use to test it in server

gunthercox commented 7 years ago

Python 3.5 is the recommended version of Python for ChatterBot. ChatterBot's requirements are listed with the version ranges specified in this file: https://github.com/gunthercox/ChatterBot/blob/master/requirements.txt

chamkank commented 7 years ago

If it still doesn't work after that, I recommend using PythonAnywhere instead of Heroku. It worked without a hitch in the past, when I hosted the live demo.

rajasimon commented 7 years ago

You should add these to your nltk.txt so heroku will download these when build.

wordnet
stopwords
punkt
vader_lexicon
vkosuri commented 7 years ago

A example project here https://github.com/vkosuri/chatterbot-live-example

gunthercox commented 7 years ago

@vkosuri Does your example still work? It looks like the heroku site may be broken.

vkosuri commented 7 years ago

No it is working https://chatterbot-live-example.herokuapp.com/

rajasimon commented 7 years ago

@vkosuri I doubt that. Can you try with fresh installation. I too ran into the same problem when I deploy in the first time.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.