Troubleshooting
This page contains tips to resolve common Prisma Client Python errors. If you've encountered an error that isn't listed on this page then please share it and we'll add it!
Client has not been generated yet
Prisma Client Python is autogenerated, this means that you must first define a Prisma Schema file and run a command before you can actually use the client.
Here's a minimal Prisma Schema file that you can copy into your project to get started with:
schema.prisma
datasource db {
provider = "sqlite"
url = "file:dev.db"
}
generator py {
provider = "prisma-client-py"
recursive_type_depth = 5
}
model User {
id String @id @default(cuid())
name String
}
You can then run prisma generate
to generate the client or you can run prisma db push
to generate the client and setup the SQLite database.
Cannot import client
In some situations it is possible that your Prisma Client Python installation becomes corrupted, this mainly occurs when upgrading from one version to another, if this is the case then we provide a helpful utility package independent of Prisma Client Python that will remove all the files that are auto-generated.
You can call it from the command line:
python -m prisma_cleanup
Or programmatically
from prisma_cleanup import cleanup
cleanup()
Custom client
If you are using a custom output directory for Prisma Client Python then you simply have to pass the import path to prisma_cleanup
, for example:
python -m prisma_cleanup app.prisma
For a custom output defined like this
generator py {
provider = "prisma-client-py"
output = "app/prisma"
}