streamlit: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0
Asked Answered
C

8

22

I previously deployed an app on Streamlit Cloud that utilized chromadb.

The app worked fine in the past. However, today I encountered a new error (as indicated in the title) and the app has stopped functioning.

I attempted to troubleshoot based on solutions from the Streamlit forum and performed the following steps sequentially:

  1. Updated the requirements.txt file by adding pysqlite3-binary.
  2. Added the following three lines of code at the top of app.py:
__import__('pysqlite3')
import sys

sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

After rebooting my app, I discovered the new error:

ModuleNotFoundError: No module named 'pysqlite3'
Traceback:
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
File "/mount/src/docgpt-streamlit/app.py", line 2, in <module>
    import pysqlite3

Subsequently, I tried adding pysqlite3 again to requirements.txt, but the error persisted.

According to the logs from manage app, I observed that Streamlit did not perform a re-pip install action.

enter image description here

Could this be causing the pysqlite error? If so, how can I correctly enable the Streamlit app to automatically pip install due to my updated requirements.txt?

Coolie answered 23/8, 2023 at 6:31 Comment(0)
D
12

I did this and it worked for me:

  1. Install pysqlite3-binary using: pip3 install pysqlite3-binary
  2. Then add below 3 lines in your code file where you have defined Chromadb

Credits: I got this answer from here: Issues with chroma and sqlite

Note: Doesn't matter if you are using django, flask or fastapi. It should work regardless.

__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
Devalue answered 28/3, 2024 at 9:35 Comment(1)
Even after installing pip3 install pysqlite3-binary. I got ModuleNotFoundError: No module named 'pysqlite3._sqlite3'.Neuburger
L
4

This was helpful, worked for me !

step 1.

pip install pysqlite3-binary

step 2. add three lines in this file /venv/lib/python3.10/site-packages/chromadb/ __init__.py

__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
Lornalorne answered 15/5, 2024 at 11:44 Comment(0)
B
2

I ran into something similar not on Streamlit Cloud but on a docker container. I SSHed in and while my python version was fine, it was running an older sqlite for some reason:

Python 3.11.3

>>> import sqlite3
>>> sqlite3.version
'2.6.0'

It turns out that I was running an older version of debian (bullseye), which Chroma's troubleshooting doc advises against, so I upped the image to python:3.11.5-bookworm and that fixed the issue.

Bloodred answered 29/9, 2023 at 1:17 Comment(0)
A
2

I met the same issues when I deployed my app on Streamlit cloud. This's my solution.

  1. Why errors?
  • My environment in local is Window 10 and my app doesn't require pysqlite3-binary when I use ChromaDB.
  • But when I deployed on streamlit cloud, the env is Linux and I have a issue like that.
  1. My solutions.
  • add pysqlite3-binary in to file requirements.txt.
  • add
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

in the first lines code. My version is

streamlit==1.28.1
chromadb==0.4.17

And in my case, it runs successfully.

Hope my solution can be useful for you.

Altorelievo answered 13/12, 2023 at 8:40 Comment(2)
How did you add pysqlite3-binary? which version?Preter
my pysqlite3-binary version is 0.5.2. I installed and import as above.Altorelievo
P
1

I solved the issue using Python 3.11 as the image:

FROM python:3.11-slim-bullseye
Preter answered 3/1, 2024 at 11:23 Comment(1)
tried, doesn't work for meIncredible
C
0

Now I've solved this problem.

The streamlit app will not re-install module even you reboot.

Therefore, I deploy the app:

  1. Delete app.
  2. ReNew app.

Then the module will re-install.

Coolie answered 23/8, 2023 at 7:36 Comment(1)
Adding pysqlite3 to requirements.txt in my case resulted in error. Just pysqlite3-binary and the lines of code did the trick. Thanks!Rubenstein
P
0

Based on pintz's answer. Example shell script/terminal commands for installing Open WebUI on RHEL 9 - has chroma and sqlite3 dependencies:

# Clone the repo...
git clone https://github.com/open-webui/open-webui.git

# change directories
cd open-webui/

# Copying required .env file
cp -RPp .env.example .env

# Building Frontend Using Node
npm i
npm run build

# Serving Frontend with the Backend
cd ./backend

# install the pysqlite3-binary  
python3.11 -m pip install pysqlite3-binary

# add pysqlite3-binary to requirements.txt (get pysqlite3-binary version using 'pip show pysqlite3-binary')
echo 'pysqlite3-binary==0.5.2.post3' >> requirements.txt

python3.11 -m pip install -r requirements.txt -U

# __import__('pysqlite3')
# import sys
# sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

# insert the imports into the main.py file  
sed -i "1 i\__import__('pysqlite3')\nimport sys\nsys.modules['sqlite3'] = sys.modules.pop('pysqlite3')" main.py

bash start.sh

# Set admin password

# Generate bcrypt hash
# htpasswd -bnBC 10 "" your-new-password | tr -d ':\n'

# update password
# sqlite3 backend/data/webui.db "UPDATE auth SET password='HASH' WHERE email='[email protected]';"

I had to install python 3.11 because base version for RHEL 9 is 3.9...

dnf install python3.11

Installing ollama and downloading dolphin-mixtral LLM for coding...

curl -fsSL https://ollama.com/install.sh | sh
ollama run dolphin-mixtral

These snippets are examples in case you want to run your own AI models using Open WebUI or see how to solve the error

RuntimeError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0. Please visit https://docs.trychroma.com/troubleshooting#sqlite to learn how to upgrade.

All commands should be ran as regular user (not root).

Piracy answered 12/5, 2024 at 19:55 Comment(0)
S
-1

maybe the version of sqlite3 is too old in your python folder. you can find it in python/DDLs/sqlite3.dll, You can right-click with your mouse, select Properties, and in the pop-up box, select Details to view the version information.

fix: download the new version from https://www.sqlite.org/download.html and replace it. and try it again. Maybe it will be OK.

by the way, my os is windows

Skirting answered 11/12, 2023 at 16:48 Comment(1)
does not work for me in streamlit application.Sheepshank

© 2022 - 2025 — McMap. All rights reserved.