ORM peewee ModuleNotFoundError: No module named 'peewee'

122 Views Asked by At

In venv, I installed the module using the command pip install peewee (it was written into requirements.txt). I wrote this code for testing and got an error: line 1, in <module> from peewee import ( ModuleNotFoundError: No module named 'peewee'. How to fix this? Python 3.12.0('venv':venv). I use VSCode

from peewee import (
    SqliteDatabase,
    Model,
    PrimaryKeyField,
    CharField,
    FloatField,
    DateField,
    ForeignKeyField,
)

db = SqliteDatabase("database.db")


class BaseModel(Model):
    id = PrimaryKeyField(unique=True)

    class Meta:
        database = db
        order_by = "id"


class Expense(Model):
    name = CharField()

    class Meta:
        db_table = "expense"


class Payment(Model):
    amount = FloatField()
    payment_date = DateField()
    expense_id = ForeignKeyField(Expense)

    class Meta:
        db_table = "payment"


# Connect to the database
db.connect()

# Create tables
db.create_tables([Expense, Payment])

I tried reinstalling the module, installing it in other projects in new venvs, restart IDE

0

There are 0 best solutions below