26

我在 virtualenv 中使用easy_install psycopg2. 我没有看到任何错误,看起来安装很顺利。在 psycopg2 的 site-packages 目录中创建了一个 egg 文件。

但是当我在解释器中运行 import psycopg2 时,我得到了以下错误..任何线索?我该如何修复它..在 virtualenv 中安装 psycopg2 的任何其他方式..

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build\bdist.win32\egg\psycopg2\__init__.py", line 69, in <module>
  File "build\bdist.win32\egg\psycopg2\_psycopg.py", line 7, in <module>
  File "build\bdist.win32\egg\psycopg2\_psycopg.py", line 6, in __bootstrap__

谢谢。

4

4 回答 4

15

Edit: this solution is outdated. Refer to this answer instead.

I had the same problem. Following the suggestion on the download page of the Windows port for getting it working on Zope worked for me under virtualenv (also in the non-virtual install):

  1. Download the executable, rename the .exe extension to .zip
  2. Extract the file contents.
  3. Copy the psycopg2 folder to MyEnv/Lib
  4. Copy the egg to MyEnv/Lib/site-packages
于 2010-09-14T02:44:30.173 回答
5

您是否检查过 PostgreSQL 的“bin”目录是否在系统路径上?快速输入“set”进行检查,看看你得到了什么。

这是 Windows 上 psycopg2 导入失败的最常见原因。

于 2010-06-16T20:42:07.007 回答
0

我使用了该命令py -m pip install "psycopg2",它对我有用。 pip install psycopg2没用。

这个链接帮助了我。

于 2021-09-20T11:43:41.177 回答
-3

有一种替代方法可以在您的计算机上安装 python 包,即pip. 您只需执行以下命令即可下载 python 包:-

    pip install psycopg2 

命令的一般格式是

    pip install [package-name]

PS:- 通过 pip 全局安装 python 包

    sudo pip install [package-name]
于 2014-09-19T13:45:26.350 回答