I'll start by saying I'm a python novice. I'm trying to run the programy chatbot webchat client on pythonanywhere.
On windows the bot is started by a shell script in the venv. I tried this and got the following error:
Initiating WebChat Client... No bot root argument set, defaulting to [../../config/xnix] WebChat Client running on http://quiraang.eu.pythonanywhere.com:8090 Healthcheck now running as part of REST Service... WebChat Client running in http mode, careful now ! * Serving Flask app "client" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 192, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/programy/clients/restful/flask/webchat/client.py", line 161, in <module> WEB_CLIENT.run(APP) File "/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/programy/clients/restful/flask/client.py", line 77, in run app.run(host=self.configuration.client_configuration.host, File "/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/flask/app.py", line 990, in run run_simple(host, port, self, **options) File "/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/werkzeug/serving.py", line 1052, in run_simple inner() File "/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/werkzeug/serving.py", line 996, in inner srv = make_server( File "/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/werkzeug/serving.py", line 847, in make_server return ThreadedWSGIServer( File "/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/werkzeug/serving.py", line 740, in __init__ HTTPServer.__init__(self, server_address, handler) File "/usr/lib/python3.8/socketserver.py", line 452, in __init__ self.server_bind() File "/usr/lib/python3.8/http/server.py", line 137, in server_bind socketserver.TCPServer.server_bind(self) File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind self.socket.bind(self.server_address) OSError: [Errno 99] Cannot assign requested address (mickey) 12:34 ~/.virtualenvs/mickey/scripts/xnix $
So I have set up the WSGI file as follows:
import sys # add your project directory to the sys.path project_home = '/home/quiraang/.virtualenvs/mickey/lib/python3.8/site- packages/programy/clients/restful/flask/webchat/' if project_home not in sys.path: sys.path = [project_home] + sys.path # import flask app but need to call it "application" for WSGI to work # from y-bot-webchat import app as application # noqa from client.py import app as application # noqa
This does not work i get the following in the error log:
Error running WSGI application ModuleNotFoundError: No module named 'client.py'; 'client' is not a package File "/var/www/quiraang_eu_pythonanywhere_com_wsgi.py", line 17, in <module> from client.py import app as application # noqa
I've probably made some basic rookie error or misunderstanding somewhere - If anyone can help I'd be very grateful