【问题标题】:Python 3.4 -> Connect to PostGres SQL using SQLAlchemy win32Python 3.4 -> 使用 SQLAlchemy win32 连接到 PostGres SQL
【发布时间】:2016-01-06 21:36:41
【问题描述】:

我正在使用 Postgres 和 Pandas,但无法连接两者。 我使用 SQLAlchemy 创建了 enginestr,如下所示

from sqlalchemy import create_engine
engine = create_engine('postgresql://postgres:password@localhost:5432/bilal')

但是,当我运行该语句时,我收到以下错误

ImportError : No module names 'psycopg2'

我已尝试安装该模块,但没有任何运气。是因为我使用的是 32 位 Windows 机器吗?

谢谢,

比拉尔

【问题讨论】:

  • 您确定错误来自您发布的那两行,而不是来自您引用 psycopg2 的地方吗?
  • 我没有成功安装 psycopg2
  • 那你应该问“如何在 Windows 32bit 上安装 psycopg2?”

标签: python postgresql python-2.7 psycopg2 python-2.x


【解决方案1】:

您是否安装正确? 使用此链接下载并安装它win-psycopg 或使用pip install psycopg2

您可以在连接字符串中指定它:

from sqlalchemy import create_engine

engine = create_engine('postgresql+psycopg2://postgres:password@localhost/bilal')

【讨论】:

  • 刚刚运行上面并从 sqlalchemy import create_engine engine = create_engine('postgresql+psycopg2://postgres:password@localhost/bilal') ImportError: No module named 'psycopg2' pip didn't install模块。 Anaconda 仅显示可用于 win64
  • 专门试一下win的第一个链接,报错说你的psycopg2没有安装,所以无法导入
  • 你有 python 3.4 / 3.5 的链接吗?
  • 我给了你两次,检查上面
猜你喜欢
  • 2021-01-29
  • 2016-04-14
  • 1970-01-01
  • 2021-10-17
  • 1970-01-01
  • 2020-05-22
  • 2013-03-22
  • 2023-02-10
  • 1970-01-01
相关资源
最近更新 更多