Ben*_*Ben 62 python django postgresql macos
在这里完成新手,试图设置Django与ProstgreSQL一起工作.
我正在使用mac osx 10.6.8.我还安装了PostgreSQL 9.3
当我pip install psycopg2在终端运行时,我收到以下错误
Downloading/unpacking psycopg2
Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
Running setup.py (path:/private/var/folders/A9/A99cs6x0FNusPejCVkYNTE+++TI/-Tmp-/pip_build_bengorman/psycopg2/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
creating pip-egg-info/psycopg2.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
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.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'.
Run Code Online (Sandbox Code Playgroud)
我已经在这个
如何安装psycopg2-with-pip-on-python pg-config-executable-not-found上看了很多帖子
但我不知道如何找到包含pg_config的bin文件夹位置.找到这条路的任何提示?
ely*_*nch 93
我建议你尝试使用Postgres.app.(http://postgresapp.com)通过这种方式,您可以在Mac上轻松打开和关闭Postgres.完成后,.profile通过附加以下内容将Postgres的路径添加到您的文件中:
PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)
只有在将Postgres添加到路径后,才能尝试psycopg2在虚拟环境(使用pip)或全局站点包中安装.
小智 32
sudo find / -name "pg_config" -print
Run Code Online (Sandbox Code Playgroud)
我的配置答案是/Library/PostgreSQL/9.1/bin/pg_config(MAC Maverick)
Dan*_*kov 28
Postgres.app最近更新了.现在它将所有二进制文件存储在"Versions"文件夹中
PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)
其中9.4 - 版本的PostgreSQL.
cpr*_*res 22
安装自制软件
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
Run Code Online (Sandbox Code Playgroud)
然后安装postgresql
brew install postgresql
Run Code Online (Sandbox Code Playgroud)
给了我这个可爱的输出:
checking for pg_config... yes
Run Code Online (Sandbox Code Playgroud)
啊啊,是的
Afr*_*ave 12
在MacOS X 10.11上安装当前的PostgreSQL应用程序后,这就是pg_config文件所在的位置/Library/PostgreSQL/9.5/bin/pg_config.
然后在终端上:
$ export PG_HOME=/Library/PostgreSQL/9.5
$ export PATH=$PATH:$PG_HOME/bin
Run Code Online (Sandbox Code Playgroud)
这会将路径放在您正在使用的终端的.profile中.
在您的环境中(假设您正在使用virtualenv),然后安装psycopg2:
$ pip install psycopg2
Run Code Online (Sandbox Code Playgroud)
您应该看看之前是否已经下载过:
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.6.1
Run Code Online (Sandbox Code Playgroud)
pg_config$ which pg_config // prints the directory location
/usr/bin/pg_config
Run Code Online (Sandbox Code Playgroud)
总结一下 - PostgreSQL根据版本号和安装方法在不同位置安装其文件(包括其二进制文件或可执行文件).
一些可能性:
/usr/local/bin/
/Library/PostgreSQL/9.2/bin/
/Applications/Postgres93.app/Contents/MacOS/bin/
/Applications/Postgres.app/Contents/Versions/9.3/bin/
Run Code Online (Sandbox Code Playgroud)
难怪人们感到困惑!
另外,如果你的$ PATH环境变量包括到包含可执行文件的目录路径(证实这一点,使用echo $PATH命令行),那么你可以跑which pg_config,which psql等找出该文件所在.