Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

ModuleNotFoundError: No module named 'psycopg2' #89

@logileifs

Description

@logileifs

I'm following the documentation and trying to use async postgres connection, everything seems to work fine until this line:
engine = sqlalchemy.create_engine(str(database.url))

then I just get this error:

~/.virtualenvs/asyncsql/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py in create_engine(*args, **kwargs)
    518     strategy = kwargs.pop("strategy", default_strategy)
    519     strategy = strategies.strategies[strategy]
--> 520     return strategy.create(*args, **kwargs)
    521 
    522 

~/.virtualenvs/asyncsql/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py in create(self, name_or_url, **kwargs)
     85                 if k in kwargs:
     86                     dbapi_args[k] = pop_kwarg(k)
---> 87             dbapi = dialect_cls.dbapi(**dbapi_args)
     88 
     89         dialect_args["dbapi"] = dbapi

~/.virtualenvs/asyncsql/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py in dbapi(cls)
    776     @classmethod
    777     def dbapi(cls):
--> 778         import psycopg2
    779 
    780         return psycopg2

ModuleNotFoundError: No module named 'psycopg2'

If I install psycopg2 everything works fine but I thought it should work with only asyncpg
Is psycopg2 a requirement even for async postgres?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions