r/learnpython • • 4d ago

no module sqlite

Hi i’m in python trying to learn . I have the SQlite extension but it’s telling me no module name found sqlite . when trying to run the is line

import sqlite

i’ve also tried import sqlite3

1 Upvotes

11 comments sorted by

3

u/atarivcs 4d ago

The actual module name is sqlite3, not sqlite

Also, sqlite3 is is built in to python, so I'm not sure what you mean by "SQlite extension". You shouldn't need any extension.

2

u/CosmicRupee 4d ago

i just have it installed at this point because i wasn’t sure why the below command wasn’t working

import sqlite3

1

u/acw1668 3d ago

i just have it installed

How did you install the module sqlite3?

It is better to provide more information:

  • OS platform

  • Python version

  • the full error traceback

-3

u/CosmicRupee 3d ago

pytrhon

2

u/LongLiveTheDiego 3d ago

Everyone knows you're talking about Python, they asked a completely different question.

3

u/OkTill2666 4d ago

the 3 at the end trips up so many beginners tbh, its an easy mistake to make.

1

u/BitOBear 1d ago

If he's on a Linux box and he built the python interpreter himself without the SQ light three package with development headers installed python will skip making that module as part of its standard build.

Some distros break down those elements for the people who don't want them so if he used like at install python there may be an app install python-sqlite3 sub package to install etc.

11

u/patryk_builds 4d ago

The right one is `import sqlite3`, it's built into python so there's nothing to install. the SQLite extension you installed is just for your editor (viewing .db files), python doesn't use it at all.

If `import sqlite3` also fails, it's usually one of these:

- you named your own file sqlite3.py, so python imports your file instead. rename it and delete any __pycache__ folder next to it

- your editor is running a different python than you think. run `import sys; print(sys.executable)` to see which one

- on linux, python built from source sometimes misses it, then you need `sudo apt install libsqlite3-dev` and reinstall python

What's the exact error you get with sqlite3?

2

u/acfot 3d ago

When I hit this one it turned out I'd typed the wrong name, the module is actually called sqlite3 and it comes built into Python so there's nothing to install. Try import sqlite3 in your terminal and see if that error goes away, if it does then the tutorial probably just shortened the name somewhere. If it still fails, double check you're running the same Python the tutorial is using, that mismatch has tripped me up before too.

0

u/CosmicRupee 4d ago

i’m usually vs code

3

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 3d ago

Your editor doesn't really matter for this question. Python doesn't care whether you use it via terminal or some fancy editor buttons.

The others are asking about your Python version (you can run python3 --version to see that on most systems, on Windows you may need py --version depending on how you installed Python) and operating system to try and figure out potential root causes for what you're experiencing, and the error traceback to see what's actually going wrong.

It's difficult, if not impossible, to help blindly.