sqlalchemy.exc.ArgumentError: Can't load plugin: sqlalchemy.dialects:driver

Here's how to produce an error like that:

>>> from sqlalchemy import *
>>> create_engine("driver://")
Traceback (most recent call last):
... etc
sqlalchemy.exc.ArgumentError: Can't load plugin: sqlalchemy.dialects:driver

so I'd say you aren't actually using the postgresql URL you think you are - you probably are calling upon a default-generated alembic.ini somewhere.


For those who haven't noticed it, the "default-generated alembic.ini" zzzzeek refers to is in the root directory of the project.

The whole problem is one of setting the sqlalchemy.url config parameter in the alembic.ini file. Also, it can be set programmatically as explained in https://stackoverflow.com/a/15668175/973380.


Notice that the scheme doesn't actually specify the driver but the dialect: the scheme is of form dialect:// or dialect+driver://.

For example the correct urls to connect to a PostgreSQL database would start with for example postgres:// (which defaults to using psycopg2), or choosing a driver explicitly (postgres+psycopg2://, or with another driver).

If you happen to specify only psycopg2 you will get the error

sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:psycopg2