【发布时间】:2011-08-03 12:23:05
【问题描述】:
如果我的开发系统(装有 OS X 10.6 的 MacBook Pro)上未安装 PostgreSQL,是否可以将 psycopg2 安装到 virtualenv 中?
当我在 virtualenv 中运行 pip install psycopg2 时,我收到了如下所示的错误。
我正在尝试使用 Django 连接到服务器上的旧数据库,如果可能的话,我不希望在我的开发系统上安装 PostgreSQL。
为什么不安装 PostgreSQL?
我在使用自制软件安装 PostgreSQL 时收到错误消息。我的 MacBook Pro 上安装了 Xcode4,而且只有 Xcode4,我认为这与缺少 gcc 4.0 有关。但是,这是另一个 StackOverflow 问题的问题。
2011 年 4 月 12 日上午 8:37 更新:我仍然想知道在我的 MacBook Pro 上不安装 PostgreSQL 的情况下是否可以这样做。但是,我运行brew update 并强制使用brew install --force ossp-uuid 重新安装ossp-uuid,现在brew install postgresql 可以工作。成功安装 PostgreSQL 后,我可以在我的 virtualenv 中pip install psycopg2。
来自pip install psycopg2 的错误
$ pip install psycopg2
Downloading/unpacking psycopg2
Running setup.py egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/matthew/.pip/pip.log
初步研究
以下是我作为初步研究阅读的文章:
【问题讨论】:
-
在这里查看正确答案:stackoverflow.com/questions/5420789/…
-
该问题的答案适用于 debian/ubuntu,因此如果您使用的是 osx,则无济于事。
-
在 Centos 6 和 Postgres 9.1 上,在你的 virtualenv 中设置正确的 pg_config 路径:
export PATH=/usr/pgsql-9.1/bin:"$PATH" -
安装 PostgreSQL 不应该是开发 django 的必要条件。我们需要这样做,因为服务器的 requirements.txt 列出了 psycopg,而我们从未在本地使用它。这一切都过于紧密耦合并导致很多配置问题。
-
哇,这篇关于 Mac 设置上的 virtualenv 细节的帖子没有一个答案。如果我错了,请纠正我。
标签: virtualenv pip psycopg2