Skip to content

Instantly share code, notes, and snippets.

@defulmere
Last active June 25, 2024 01:24
Show Gist options
  • Save defulmere/8b9695e415a44271061cc8e272f3c300 to your computer and use it in GitHub Desktop.
Save defulmere/8b9695e415a44271061cc8e272f3c300 to your computer and use it in GitHub Desktop.
How to override an old sqlite3 module with pysqlite3 in django settings.py
# ⚠️ USE AT YOUR OWN RISK
# first: pip install pysqlite3-binary
# then in settings.py:
# these three lines swap the stdlib sqlite3 lib with the pysqlite3 package
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
@cmosta0
Copy link

cmosta0 commented Jan 2, 2024

Bump, I'm having the same issue as @cmosta0 . Any workaround?

Hi. In my case, the issue seems to be related the OS. Actually to be able to install using pip, I needed to use --platform on pip install command, otherwise every attempt just returned the same error mentioned above. (I'm using macbook-pro M2)

@gavinnwang
Copy link

@cmosta0 Hey what is the pip install command you used to successfully install the binary? Thanks in advance

@sunshicheng1
Copy link

thinks , u solve my problem, very thinks

@atozharsh
Copy link

@defulmere Thank you very much. This worked for me as well.

@asiff00
Copy link

asiff00 commented Mar 13, 2024

This was helpful, worked for me as well !

I was getting following error while trying to run chromadb example code using my python3.10.8 venv3.10: File "~/venv3.10/lib/python3.10/site-packages/chromadb/__init__.py", line 36, in <module> raise RuntimeError( RuntimeError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.

I executed following steps to resolve this error:

  1. Inside my python3.10.8's virtual environment i.e. venv3.10, installed pysqlite3-binary using command: pip install pysqlite3-binary
  2. Added these 3 lines in venv3.10/lib/python3.10/site-packages/chromadb/__init__.py at the beginning:
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

worked like magic! Thank you!

@cgorricho
Copy link

I tried this couple of months ago and worked, however now it doesn't. the issue is that I'm not even able to install the dependency:

pip install pysqlite3-binary  

ERROR: Could not find a version that satisfies the requirement pysqlite3-binary (from versions: none)
ERROR: No matching distribution found for pysqlite3-binary

I saw the packages are still with the same name on pypi and they were not removed, but not sure what changed and does not work now.

Any ideas?

It also happened to me, until I realized it only works on Linux.

See Chroma's documentation

@Qammarbhat
Copy link

What do we have to do, if we are deploying on streamlit?

@thubamamba
Copy link

I found that on your local, just delete your virtual environment, recreate it with python 3.10, run pip install -r requirements.txt and you'll be good.

I tried this couple of months ago and worked, however now it doesn't. the issue is that I'm not even able to install the dependency:

pip install pysqlite3-binary  

ERROR: Could not find a version that satisfies the requirement pysqlite3-binary (from versions: none)
ERROR: No matching distribution found for pysqlite3-binary

I saw the packages are still with the same name on pypi and they were not removed, but not sure what changed and does not work now.
Any ideas?

It also happened to me, until I realized it only works on Linux.

See Chroma's documentation

@boobafhir
Copy link

Persistent Issue: Unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0
What is the solution if we are deploying streamlit App.
Our Streamlit App is working fine on local but after Deployment on Streamlit Cloud the issue occurred

@xke
Copy link

xke commented Jun 10, 2024

Hey, so I was able to bypass this issue by just adding pysqlite3-binary to requirements.txt

Did not have to add any versioning, or other code.

@rajkaran27
Copy link

This was helpful, worked for me as well !

I was getting following error while trying to run chromadb example code using my python3.10.8 venv3.10: File "~/venv3.10/lib/python3.10/site-packages/chromadb/__init__.py", line 36, in <module> raise RuntimeError( RuntimeError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.

I executed following steps to resolve this error:

  1. Inside my python3.10.8's virtual environment i.e. venv3.10, installed pysqlite3-binary using command: pip install pysqlite3-binary
  2. Added these 3 lines in venv3.10/lib/python3.10/site-packages/chromadb/__init__.py at the beginning:
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

And my code worked like a charm!

Thank you so much, this worked

@sahilgarg231297
Copy link

How to manage updating ~/venv3.10/lib/python3.10/site-packages/chromadb/__init__.py in server running with docker?

@zengyunda
Copy link

这很有帮助,对我也很有用!

当我尝试使用我的 python3.10.8 venv3.10 运行 chromadb 示例代码时出现以下错误: File "~/venv3.10/lib/python3.10/site-packages/chromadb/__init__.py", line 36, in <module> raise RuntimeError( RuntimeError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.

我执行了以下步骤来解决此错误:

  1. 在我的 python3.10.8 的虚拟环境即 venv3.10 中,使用命令安装了 pysqlite3-binary:pip install pysqlite3-binary
  2. venv3.10/lib/python3.10/site-packages/chromadb/__init__.py在开头添加了以下3行:
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

我的代码运行得非常好!

very good ! 3Q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment