ModuleNotFoundError:没有名为“ psycopg2.errors”的模块

时间:2019-12-06 17:46:39

标签: python import psycopg2

我已安装psycopg2模块,但无法从该库中导入异常:

$ pip freeze | grep psycopg
psycopg2==2.7.7
$ python
Python 3.7.4 (default, Nov  5 2019, 17:21:00)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> from psycopg2.errors import InsufficientPrivilege, UndefinedTable
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'psycopg2.errors'

1 个答案:

答案 0 :(得分:0)

作为@john-gordon mentioned

<块引用>

psycopg2.errors 是在 2.8 版本中引入的。