ImportError:没有名为postgresql的模块,已经安装了psycopg2

时间:2015-04-16 11:34:53

标签: python postgresql python-module

为了安装OpenGnSys,我们需要运行脚本然后调用python脚本。这个python脚本给出以下错误:

[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

在网上搜索后,我发现应为psycopg2安装模块postgesql。但就我而言,它已经存在了。可能是什么问题?

2 个答案:

答案 0 :(得分:0)

Are we talking about a misconfiguration of the url

postgresql://opengnsys:opengnsys@localhost/opengnsys

vs

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

答案 1 :(得分:0)

尝试指定端口号,即3306