vutran1710 / PyrateLimiter

⚔️Python Rate-Limiter using Leaky-Bucket Algorithm Family
https://pyratelimiter.readthedocs.io
MIT License
336 stars 36 forks source link

ModuleNotFoundError: No module named '_sqlite3' - importing pyratelimiter as poetry dependency. Using MemoryListBucket but still getting sqlite error #89

Closed zepto-ani closed 1 year ago

zepto-ani commented 1 year ago
from pyrate_limiter import Limiter, Duration, RequestRate, MemoryListBucket

File "/home/ec2-user/.cache/pypoetry/virtualenvs/app-5tQquC-A-py3.9/lib/python3.9/site-packages/pyrate_limiter/init.py", line 9, in from .sqlite_bucket import File "/home/ec2-user/.cache/pypoetry/virtualenvs/app-5tQquC-A-py3.9/lib/python3.9/site-packages/pyrate_limiter/sqlite_bucket.py", line 1, in import sqlite3 File "/home/ec2-user/.cache/pypoetry/virtualenvs/app-5tQquC-A-py3.9/lib/python3.9/site-packages/newrelic/api/import_hook.py", line 173, in exec_module self.loader.exec_module(module) File "/usr/local/lib/python3.9/sqlite3/init.py", line 23, in from sqlite3.dbapi2 import File "/home/ec2-user/.cache/pypoetry/virtualenvs/app-5tQquC-A-py3.9/lib/python3.9/site-packages/newrelic/api/import_hook.py", line 173, in exec_module self.loader.exec_module(module) File "/usr/local/lib/python3.9/sqlite3/dbapi2.py", line 27, in from _sqlite3 import * ModuleNotFoundError: No module named '_sqlite3'

JWCook commented 1 year ago

Sqlite3 is part of the python standard library, but there are a few rare situations where it's explicitly disabled. It looks like you're running on EC2, which I've never seen do that before. What instance type and AMI are you using?

Anyway, to accommodate this in pyrate-limiter, the sqlite3 import could be moved to function scope instead of module scope.

vutran1710 commented 1 year ago

Closed due to inactivity