Quick answer
Install the latest Microsoft Visual C++ Redistributable (x64 and x86) and restart your command prompt. That fixes 9 out of 10 cases.
Why this happens
Python's sqlite3 module is a wrapper around the SQLite C library. On Windows, that library ships as a DLL (sqlite3.dll) that Python loads at runtime. If Windows can't find the DLL, you get that cryptic DLL load failed error. The usual culprit is a missing or outdated Visual C++ Redistributable, because SQLite's DLL depends on the VC++ runtime. I've seen this on fresh Windows installs and on machines where someone cleaned out system files with a junk cleaner. One client last month got it after a Windows update reset some PATH variables. Annoying, but fixable.
Fix steps
- Install the VC++ Redistributables. Go to Microsoft's official download page and grab both
vc_redist.x64.exeandvc_redist.x86.exe. Run both, even if you're on 64-bit. Python can be 32-bit even on 64-bit Windows. Restart your terminal after. - Check your Python architecture. Run
python -c "import platform; print(platform.architecture())"in your command prompt. If it says32bit, you need the x86 redistributable. If it says64bit, the x64 one. But install both anyway—cheap insurance. - Verify the sqlite3 module. Open a fresh terminal and run
python -c "import sqlite3; print(sqlite3.sqlite_version)". If it prints a version like3.45.1, you're good. If it throws the same error, move on. - Check if you have multiple Python installations. Run
where pythonin the command prompt. If you see more than one path, you might be running a different Python than the one where you installed packages. Use the full path to the Python you want, or set the PATH correctly. - Reinstall Python. Sometimes the DLL gets corrupted or missing during an update. Uninstall Python completely, reboot, then install the latest version from python.org. Make sure to check "Add Python to PATH" during install.
Alternative fixes
If the main fix doesn't work, try these:
- Copy sqlite3.dll manually. Download the SQLite DLL from sqlite.org (the "sqlite-dll-win64-x64" if you're 64-bit, "win32" if 32-bit). Put the
sqlite3.dllfile in the same folder as your Python executable, or inC:\Windows\System32(for 64-bit) orC:\Windows\SysWOW64(for 32-bit). This is a hack, but it works in a pinch. - Use a virtual environment. Create a fresh venv:
python -m venv myenv, then activate it and test. Sometimes the system Python is messed up but a venv uses its own copy. - Check for antivirus interference. Some AV software quarantines the DLL because it's a legitimate but uncommon file. Add an exception for your Python folder and the DLL.
Prevention tips
Keep the VC++ redistributables updated. Microsoft pushes them via Windows Update, but sometimes they lag. Also, don't delete anything from C:\Windows\System32—I know it looks like junk, but that's where the DLLs live. If you're a developer, use a virtual environment for each project. That isolates you from system-level issues. And if you're on a work computer, ask IT before running anything—had a guy get locked out of his machine once because he tried to fix this himself and broke his PATH. Good luck.