Question

I'm trying to run my application with peewee on a server and it keeps crashing.

To start the application the start function is called in main.py:

def start(db_name, db_user, db_pass):
    BaseModel.initialize_database(db_name, db_user, db_pass)
    classA.create_table()
    classB.create_table()
    return app

It crashes on the first line in the BaseModel class.

from peewee import MySQLDatabase
from peewee import Model

I get the following error: "ImproperlyConfigured: Either sqlite3, psycopg2 or MySQLdb must be installed".

I don't understand the error because the database is running on the same server. The database was created using phpmyadmin.

When I test the application on my laptop everything works fine, for testing I use an SQLite database "test.db".

Était-ce utile?

La solution

Peewee was unable to import any of the known database drivers. Try running this from your interactive shell:

import sqlite3
import psycopg2
import MySQLdb

If they all fail with an import error, then that would explain your issue.

Autres conseils

In Pycharm:

  1. click File
  2. click settings
  3. on Project interpreter tap , select install button (Plus shape)
  4. Search on mysql and install it
  5. search on mysql-connector and install it
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top