I'm trying to work through part of the Flask tutorial (https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-x-email-support) to add email support for my Flask app. However, after adding the code, I get an error whenever I try to load any page on my Flask. The error log shows:
2019-12-31 04:34:25,908: Error running WSGI application
2019-12-31 04:34:25,910: ModuleNotFoundError: No module named 'SocketServer'
2019-12-31 04:34:25,910: File "/var/www/jplank_pythonanywhere_com_wsgi.py", line 16, in <module>
2019-12-31 04:34:25,910: from flask_app import app as application # noqa
2019-12-31 04:34:25,910:
2019-12-31 04:34:25,910: File "/home/jplank/mysite/flask_app.py", line 2, in <module>
2019-12-31 04:34:25,910: from flask_sqlalchemy import SQLAlchemy
2019-12-31 04:34:25,910:
2019-12-31 04:34:25,911: File "/usr/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 14, in <module>
2019-12-31 04:34:25,911: from flask import _app_ctx_stack, abort, current_app, request
2019-12-31 04:34:25,911:
2019-12-31 04:34:25,911: File "/usr/lib/python3.8/site-packages/flask/__init__.py", line 16, in <module>
2019-12-31 04:34:25,911: from werkzeug.exceptions import abort
2019-12-31 04:34:25,911:
2019-12-31 04:34:25,911: File "/usr/lib/python3.8/site-packages/werkzeug/__init__.py", line 218, in <module>
2019-12-31 04:34:25,912: from .serving import run_simple
2019-12-31 04:34:25,912:
2019-12-31 04:34:25,912: File "/usr/lib/python3.8/site-packages/werkzeug/serving.py", line 59, in <module>
2019-12-31 04:34:25,912: import SocketServer as socketserver
2019-12-31 04:34:25,912: ***************************************************
2019-12-31 04:34:25,912: If you're seeing an import error and don't know why,
2019-12-31 04:34:25,912: we have a dedicated help page to help you debug:
2019-12-31 04:34:25,913: https://help.pythonanywhere.com/pages/DebuggingImportError/
2019-12-31 04:34:25,913: ***************************************************
Can anyone help me understand what might be causing the error? My googling shows that there was once an error with werkzeug with the line " import SocketServer as socketserver" but that it's since been fixed. The problem seemed to be that socketserver should be lowercase for python 3+. And when I look at the code in serving.py, it shows:
try:
import socketserver
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
except ImportError:
import SocketServer as socketserver
from BaseHTTPServer import HTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler
So, it does actually look like it ought to be using the "import socketserver" line. I'm just really confused what's going on here. Can anyone help?