0

I was able to run flask run till yesterday. But today it is not working, it has been giving errors for SQL and I have been able to code today. It gives me this error continuously.

ERROR: Error on request:
Traceback (most recent call last):
File "/home/ubuntu/workspace/finance/application.py", line 36, in <module>
db = SQL("sqlite:///finance.db")
File "/usr/local/lib/python3.9/site-packages/cs50/sql.py", line 47, in __init__
import sqlite3
File "/usr/local/lib/python3.9/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.9/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.9/site-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 338, in __call__
self._flush_bg_loading_exception()
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 326, in _flush_bg_loading_exception
reraise(*exc_info)
File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 314, in _load_app
self._load_unlocked()
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 330, in _load_unlocked
self._app = rv = self.loader()
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 388, in load_app
app = locate_app(self, import_name, name)
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 245, in locate_app
raise NoAppException(
flask.cli.NoAppException: While importing "application", an ImportError was raised:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/ubuntu/workspace/finance/application.py", line 36, in <module>
db = SQL("sqlite:///finance.db")
File "/usr/local/lib/python3.9/site-packages/cs50/sql.py", line 47, in __init__
import sqlite3
File "/usr/local/lib/python3.9/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.9/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
INFO: 192.168.25.115 - - [01/Jan/2021 17:11:12] "GET /favicon.ico HTTP/1.0" 500 -
ERROR: Error on request:
Traceback (most recent call last):
File "/home/ubuntu/workspace/finance/application.py", line 36, in <module>
db = SQL("sqlite:///finance.db")
File "/usr/local/lib/python3.9/site-packages/cs50/sql.py", line 47, in __init__
import sqlite3
File "/usr/local/lib/python3.9/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.9/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.9/site-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 343, in __call__
rv = self._load_unlocked()
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 330, in _load_unlocked
self._app = rv = self.loader()
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 388, in load_app
app = locate_app(self, import_name, name)
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 245, in locate_app
raise NoAppException(
flask.cli.NoAppException: While importing "application", an ImportError was raised:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/ubuntu/workspace/finance/application.py", line 36, in <module>
db = SQL("sqlite:///finance.db")
File "/usr/local/lib/python3.9/site-packages/cs50/sql.py", line 47, in __init__
import sqlite3
File "/usr/local/lib/python3.9/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.9/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

2 Answers 2

1

Install sqlite3 with the command pip install pysqlite3. Can't say whether future 2021 changes to the IDE will render this moot, but it worked for me!

0
0

Having the same problem. I believe the IDE now uses python 9, and that cant use sqlite3 or at least it isn't set up correctly or installed in the right directory :(

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .