encode / orm

An async ORM. 🗃
https://www.encode.io/orm
BSD 3-Clause "New" or "Revised" License
1.78k stars 98 forks source link

ModuleNotFoundError: No module named 'psycopg2' #89

Closed logileifs closed 3 years ago

logileifs commented 3 years ago

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?

miss85246 commented 3 years ago

Hello, I also encountered a similar problem. I found that the version on pipy is 0.1.5, but the version on github is 0.1.4. Please try to install 0.1.4, which may solve your problem.

meysam81 commented 3 years ago

@miss85246 @logileifs Have you tried pip install databases[postgresql]?