TPS
TPS

Reputation: 518

ImportError: No module named postgresql, Already installed psycopg2

For installing OpenGnSys, we need to run script which then calls python script. This python script gives following error:

[root@custrohitkr opengnsys2-web]# ./db.py 
postgresql://opengnsys:opengnsys@localhost/opengnsys
Traceback (most recent call last):
  File "./db.py", line 88, in <module>
    create()
  File "./db.py", line 81, in create
    db = create_engine(database, echo=False)
  File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/__init__.py", line 223, in create_engine
    return strategy.create(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/strategies.py", line 48, in create
    dialect_cls = u.get_dialect()
  File "/usr/lib/python2.6/site-packages/sqlalchemy/engine/url.py", line 91, in get_dialect
    module = getattr(__import__('sqlalchemy.databases.%s' % self.drivername).databases, self.drivername)
ImportError: No module named postgresql

After searching on net I found that module psycopg2 should be installed for postgesql. But in my case it is already there. What may be the issue?

Upvotes: 2

Views: 3364

Answers (3)

Athif Saheer
Athif Saheer

Reputation: 4647

I faced the same issue and solved it with the below steps!

pip install psycopg2-binary

Add URL like below

db+postgresql://postgres:1234@localhost/mydb

Upvotes: -1

Aaron
Aaron

Reputation: 1

try specifying a port number, ie 3306

Upvotes: 0

John Mee
John Mee

Reputation: 52253

Are we talking about a misconfiguration of the url

postgresql://opengnsys:opengnsys@localhost/opengnsys

vs

postgresql+psycopg2://scott:tiger@localhost/mydatabase

Upvotes: 1

Related Questions