Ruby on rails 在Rails项目中执行捆绑安装时出错

Ruby on rails 在Rails项目中执行捆绑安装时出错,ruby-on-rails,Ruby On Rails,我在安装捆绑包时遇到此错误 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20141021-16973-pl84tb.rb extconf.rb checking for pg_config... no No pg_config... trying

我在安装捆绑包时遇到此错误

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20141021-16973-pl84tb.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
 --with-pg
 --without-pg
 --with-pg-config
 --without-pg-config
 --with-pg_config
 --without-pg_config
 --with-pg-dir
 --without-pg-dir
 --with-pg-include
 --without-pg-include=${pg-dir}/include
 --with-pg-lib
 --without-pg-lib=${pg-dir}/
extconf failed, exit code 1
Gem files will remain installed in /var/folders/lz/tx91rz_x7njcbv6qnftv9tnw0000gn/T/bundler20141021-16973-1or046s/pg-0.17.1/gems/pg-0.17.1 for inspection.
Results logged to /var/folders/lz/tx91rz_x7njcbv6qnftv9tnw0000gn/T/bundler20141021-16973-1or046s/pg-0.17.1/extensions/universal-darwin-13/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot
continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
然后我试着

sudo gem install pg -v '0.17.1'
收到了这个错误信息

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20141021-16998-1dyvwx6.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.17.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/pg-0.17.1/gem_make.out
我不知道这是否与我的rails路径有关。因为我的python有路径问题,并且无法正确安装所有模块,所以我使用了virtualenv for python。ruby有类似virtualenv的东西吗?
有人知道怎么修吗?我是RubyonRails的新手,谢谢:

这个错误与PostgreSQL有关,看起来Rails应用程序中有一个PGGem。你已经在你的系统上安装了PostgreSQL吗?@Ali我不知道我是否安装了PostgreSQL,你能告诉我如何检查吗?