ModuleNotFoundError: No module named '_sqlite3' on a Python Flask application

When I deploy my application (Python + Flask), I have a module import error:

2022-12-19T23:04:12.794 app[83761953] cdg [info] File "/workspace/app.py", line 18, in <module>
2022-12-19T23:04:12.794 app[83761953] cdg [info] from db import Database
2022-12-19T23:04:12.794 app[83761953] cdg [info] File "/workspace/db.py", line 2, in <module>
2022-12-19T23:04:12.794 app[83761953] cdg [info] import sqlite3
2022-12-19T23:04:12.794 app[83761953] cdg [info] File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.10/sqlite3/__init__.py", line 57, in <module>
2022-12-19T23:04:12.794 app[83761953] cdg [info] from sqlite3.dbapi2 import *
2022-12-19T23:04:12.794 app[83761953] cdg [info] File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.10/sqlite3/dbapi2.py", line 27, in <module>
2022-12-19T23:04:12.794 app[83761953] cdg [info] from _sqlite3 import *
2022-12-19T23:04:12.794 app[83761953] cdg [info] ModuleNotFoundError: No module named '_sqlite3' 

I have tried to use the paketobuildpacks/builder:full instead of paketobuildpacks/builder:base as suggested here, but it doesn’t fix the problem.

Any idea?

Hi, new user of Fly.io,
very same problem.
PS : Sorry for the deleted post (wrong click).

Looks like somes have the same issue.

This situation is a shame, it seems that the fly.io team really doesn’t care about Python users.

BTW use Heroku buildpack instead of the Paketo one, editing your fly.toml file after generation.

[build]
  builder = "heroku/buildpacks:latest"
1 Like

We don’t have anyone working on Python support yet, it’s entirely community driven.

The Heroku buildpack may work, but it’ll be very slow.

Your best bet for Flask is to write a Dockerfile. We’ll happily build and deploy a Dockerfile. There are probably hundreds of good Flask Dockerfile examples on the internet.

As you know, Python is a great and one of the most used programming language so… why so few love from the fly team ?

The Heroku buildpack works fine for me on fly, not slow…

Thanks! It works perfectly! :smiley: