如何在Python中使用“pip”安装psycopg2 ?

时间:2022-08-28 20:29:28

I'm using virtualenv and I need to install "psycopg2".

我正在使用virtualenv,我需要安装“psycopg2”。

I have done the following:

我做了以下工作:

pip install http://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160

And I have the following messages:

我有以下信息:

Downloading/unpacking http://pypi.python.org/packages/source/p/psycopg2/psycopg2
-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
  Downloading psycopg2-2.4.tar.gz (607Kb): 607Kb downloaded
  Running setup.py egg_info for package from http://pypi.python.org/packages/sou
rce/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
    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'.

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in C:\Documents and Settings\anlopes\Application Data\pip\p
ip.log

My question, I only need to do this to get the psycopg2 working?

我的问题是,我只需要做这个就能让psycopg2工作?

python setup.py build_ext --pg-config /path/to/pg_config build ...

26 个解决方案

#1


664  

I found this post searching for a Linux solution to this problem.

我发现这个帖子是在寻找解决这个问题的Linux解决方案。

This post by "goshawk" gave me the solution: run sudo apt-get install libpq-dev python-dev if you are on Ubuntu/Debian.

“goshawk”这篇文章给了我一个解决方案:如果你在Ubuntu/Debian上,运行sudo apt-get来安装libpq-dev pythondev。

Update

Since more people have found this answer useful and posted their own solutions, here's a list of them:

由于越来越多的人发现这个答案很有用,并且发布了自己的解决方案,下面列出了他们的一个列表:

Debian/Ubuntu

Python 2

sudo apt install libpq-dev python-dev

Python 3

sudo apt install libpq-dev python3-dev

Additional

If none of the above solve your issue, try

如果以上这些都不能解决你的问题,那就试试吧。

sudo apt install build-essential

or

sudo apt install postgresql-server-dev-all

#2


110  

On CentOS, you need the postgres dev packages:

在CentOS,您需要postgres开发包:

sudo yum install python-devel postgresql-devel

That was the solution on CentOS 6 at least.

这至少是CentOS 6的解决方案。

#3


79  

On Mac Mavericks with Postgres.app version 9.3.2.0 RC2 I needed to use the following code after installing Postgres:

在Mac Mavericks和Postgres。app版本9.3.2.0 RC2安装Postgres后需要使用以下代码:

sudo PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin pip install psycopg2

sudo PATH=$PATH:/应用程序/Postgres.app/内容/版本/9.3/bin pip安装psycopg2。

#4


67  

if you're on a mac you can use homebrew

如果你在mac电脑上,你可以使用自制软件。

brew install postgresql

And all other options are here: http://www.postgresql.org/download/macosx/

所有其他选项都在这里:http://www.postgresql.org/download/macosx/。

Good luck

祝你好运

#5


59  

I recently configured psycopg2 on a windows machine. The easiest install is using a windows executable binary. You can find it at http://stickpeople.com/projects/python/win-psycopg/.

我最近在一台windows机器上配置了psycopg2。最简单的安装是使用windows可执行二进制文件。你可以在http://stickpeople.com/projects/python/win-psycopg/找到它。

To install the native binary in a virtual envrionment, use easy_install:

要在虚拟环境中安装本机二进制文件,请使用easy_install:

C:\virtualenv\Scripts\> activate.bat
(virtualenv) C:\virtualenv\Scripts\> easy_install psycopg2-2.5.win32-py2.7-pg9.2.4-release.exe

#6


27  

For Python 3 you should use sudo apt-get install libpq-dev python3-dev under Debian.

对于Python 3,您应该使用sudo apt-get在Debian下安装libpq-dev python3-dev。

#7


24  

This is what worked for me (On RHEL, CentOS:

这就是我的工作(在RHEL, CentOS:

sudo yum install postgresql postgresql-devel python-devel

And now include the path to your postgresql binary dir with you pip install:

现在,在您的pip安装中包含您的postgresql二进制目录的路径:

sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2

Make sure to include the correct path. Thats all :)

确保包含正确的路径。这是所有:)

UPDATE: For python 3, please install python3-devel instead of python-devel

更新:对于python3,请安装python3-devel而不是python-devel。

#8


21  

If you using Mac OS, you should install PostgreSQL from source. After installation is finished, you need to add this path using:

如果使用Mac OS,则应该从源代码安装PostgreSQL。安装完成后,您需要使用以下方法添加以下路径:

export PATH=/local/pgsql/bin:$PATH

or you can append the path like this:

或者你可以这样添加路径:

export PATH=.../:usr/local/pgsql/bin

in your .profile file or .zshrc file.

在您的.profile文件或.zshrc文件中。

This maybe vary by operating system.

这可能因操作系统而异。

You can follow the installation process from http://www.thegeekstuff.com/2009/04/linux-postgresql-install-and-configure-from-source/

您可以按照安装过程从http://www.thegeekstuff.com/2009/04/linux-postgresql- installandconfigurefrom-source/。

#9


16  

The answers so far are too much like magic recipes. The error that you received tells you that pip cannot find a needed part of the PostgreSQL Query library. Possibly this is because you have it installed in a non-standard place for your OS which is why the message suggests using the --pg-config option.

到目前为止,答案就像魔术食谱一样。您收到的错误告诉您,pip无法找到PostgreSQL查询库所需的部分。这可能是因为您已经将它安装在您的操作系统的非标准位置,这就是为什么消息建议使用-pg-config选项。

But a more common reason is that you don't have libpq installed at all. This commonly happens on machines where you do NOT have PostgreSQL server installed because you only want to run client apps, not the server itself. Each OS/distro is different, for instance on Debian/Ubuntu you need to install libpq-dev. This allows you to compile and link code against the PostgreSQL Query library.

但更常见的原因是,您根本没有安装libpq。这通常发生在您没有安装PostgreSQL服务器的机器上,因为您只希望运行客户机应用程序,而不是服务器本身。每个OS/发行版不同,例如在Debian/Ubuntu上,您需要安装libpq-dev。这允许您在PostgreSQL查询库中编译和链接代码。

Most of the answers also suggest installing a Python dev library. Be careful. If you are only using the default Python installed by your distro, that will work, but if you have a newer version, it could cause problems. If you have built Python on this machine then you already have the dev libraries needed for compiling C/C++ libraries to interface with Python. As long as you are using the correct pip version, the one installed in the same bin folder as the python binary, then you are all set. No need to install the old version.

大多数答案还建议安装Python dev库。小心些而已。如果您只使用发行版所安装的默认Python,那么这将起作用,但是如果您有一个较新的版本,它可能会导致问题。如果您在这台机器上构建了Python,那么您已经有了编译C/ c++库和Python接口所需的开发库。只要您使用的是正确的pip版本,安装在与python二进制文件相同的bin文件夹中,那么您就全部设置好了,不需要安装旧版本。

#10


12  

On Debian/Ubuntu:

在Debian / Ubuntu:

First install and build dependencies of psycopg2 package:

首先安装和构建psycopg2包的依赖项:

# apt-get build-dep python-psycopg2

Then in your virtual environment, compile and install psycopg2 module:

然后在虚拟环境中,编译并安装psycopg2模块:

(env)$ pip install psycopg2

#11


6  

I've done this before where in windows you install first into your base python installation.

我已经在windows中首先安装到您的基础python安装中完成了这一操作。

Then, you manually copy the installed psycopg2 to the virtualenv install.

然后,您手动复制安装的psycopg2到virtualenv安装。

It's not pretty, but it works.

它不漂亮,但很管用。

#12


5  

Besides installing the required packages, I also needed to manually add PostgreSQL bin directory to PATH.
$vi ~/.bash_profile
Add PATH=/usr/pgsql-9.2/bin:$PATH before export PATH.
$source ~/.bash_profile
$pip install psycopg2

除了安装所需的包之外,我还需要手动地将PostgreSQL bin目录添加到PATH中。vi ~ /美元。bash_profile Add PATH=/usr/pgsql-9.2/bin:$PATH在导出路径之前。源~ /美元。bash_profile pip安装psycopg2美元

#13


3  

On windows XP you get this error if postgres is not installed ...

在windows XP上,如果没有安装postgres,就会出现这个错误……

#14


3  

I installed Postgresql92 using the RedHat / CentOS repository on PG's downloads site http://www.postgresql.org/download/linux/redhat/

我在PG的下载网站http://www.postgresql.org/download/linux/redhat/中使用RedHat / CentOS存储库安装了Postgresql92。

To get pg_config, I had to add /usr/pgsql-9.2/bin to PATH.

为了获得pg_config,我必须添加/usr/pgsql-9.2/bin到PATH。

#15


2  

I've been battling with this for days, and have finally figured out how to get the "pip install psycopg2" command to run in a virtualenv in Windows (running Cygwin).

我已经和这个问题斗争了好几天,终于找到了如何让“pip安装psycopg2”命令在Windows(运行Cygwin)的virtualenv中运行。

I was hitting the "pg_config executable not found." error, but I had already downloaded and installed postgres in Windows. It installed in Cygwin as well; running "which pg_config" in Cygwin gave "/usr/bin/pg_config", and running "pg_config" gave sane output -- however the version installed with Cygwin is:

我正在点击“pg_config可执行文件未找到”错误,但我已经在Windows中下载并安装了postgres。它也安装在Cygwin中;在Cygwin中运行的“pg_config”提供了“/usr/bin/pg_config”,运行“pg_config”使输出正常——但是安装了Cygwin的版本是:

VERSION = PostgreSQL 8.2.11

VERSION = PostgreSQL 8.2.11

This won't work with the current version of psycopg2, which appears to require at least 9.1. When I added "c:\Program Files\PostgreSQL\9.2\bin" to my Windows path, the Cygwin pip installer was able to find the correct version of PostgreSQL, and I was able to successfully install the module using pip. (This is probably preferable to using the Cygwin version of PostgreSQL anyway, as the native version will run much quicker).

这与当前的psycopg2版本不兼容,后者似乎至少需要9.1。当我将“c:\程序文件\PostgreSQL\9.2\bin”添加到我的Windows路径时,Cygwin pip安装程序能够找到正确的PostgreSQL版本,并且我能够成功地使用pip安装模块。(这可能比使用PostgreSQL的Cygwin版本更可取,因为本机版本将运行得更快)。

#16


2  

On Fedora 24: For Python 3.x

Fedora 24:用于Python 3.x。

sudo dnf install postgresql-devel python3-devel

sudo dnf install redhat-rpm-config

Activate your Virtual Environment:

激活你的虚拟环境:

pip install psycopg2

#17


1  

For lowly Windows users were stuck having to install psycopg2 from the link below, just install it to whatever Python installation you have setup. It will place the folder named "psycopg2" in the site-packages folder of your python installation.

对于底层的Windows用户,他们不得不从下面的链接安装psycopg2,只需安装到您安装的任何Python安装中。它将把名为“psycopg2”的文件夹放在python安装的站点包文件夹中。

After that, just copy that folder to the site-packages directory of your virtualenv and you will have no problems.

之后,只需将该文件夹复制到virtualenv的站点包目录,就不会出现问题。

here is the link you can find the executable to install psycopg2

这里是链接,您可以找到可执行程序来安装psycopg2。

http://www.lfd.uci.edu/~gohlke/pythonlibs/

http://www.lfd.uci.edu/ gohlke / pythonlibs /

#18


1  

On OpenSUSE 13.2, this fixed it:

在OpenSUSE 13.2上,这是固定的:

sudo zypper in postgresql-devel 

#19


1  

I could install it in a windows machine and using Anaconda/Spyder with python 2.7 through the following commands:

我可以将它安装在windows机器中,并通过以下命令使用python 2.7的Anaconda/Spyder:

 !pip install psycopg2

Then to establish the connection to the database:

然后建立与数据库的连接:

 import psycopg2
 conn = psycopg2.connect(dbname='dbname',host='host_name',port='port_number', user='user_name', password='password')

#20


1  

In Arch base distributions:

在拱基地分布:

sudo pacman -S python-psycopg2
pip2 install psycopg2  # Use pip or pip3 to python3

#21


1  

Psycopg2 Depends on Postgres Libraries. On Ubuntu You can use:

Psycopg2依赖于Postgres库。在Ubuntu上你可以使用:

apt-get install libpq-dev

Then:

然后:

pip install psycopg2

#22


0  

On Ubuntu I just needed the postgres dev package:

在Ubuntu上,我只需要postgres开发包:

sudo apt-get install postgresql-server-dev-all

*Tested in a virtualenv

* virtualenv中进行测试

#23


0  

On OSX 10.11.6 (El Capitan)

osx10.11.6 (El Capitan)

brew install postgresql
PATH=$PATH:/Library/PostgreSQL/9.4/bin pip install psycopg2

#24


0  

On OSX with macports:

在OSX macports:

sudo port install postgresql96
export PATH=/opt/local/lib/postgresql96/bin:$PATH

#25


0  

if pip is not working than you can download .whl file from here https://pypi.python.org/pypi/psycopg2 extract it.. than python setup.py install

如果pip不工作,你可以从这里下载。whl文件,https://pypi.python.org/pypi/psycopg2提取它。比python设置。py安装

#26


-1  

Try this in Gentoo:

在Gentoo试试这个:

emerge dev-libs/libpqxx

#1


664  

I found this post searching for a Linux solution to this problem.

我发现这个帖子是在寻找解决这个问题的Linux解决方案。

This post by "goshawk" gave me the solution: run sudo apt-get install libpq-dev python-dev if you are on Ubuntu/Debian.

“goshawk”这篇文章给了我一个解决方案:如果你在Ubuntu/Debian上,运行sudo apt-get来安装libpq-dev pythondev。

Update

Since more people have found this answer useful and posted their own solutions, here's a list of them:

由于越来越多的人发现这个答案很有用,并且发布了自己的解决方案,下面列出了他们的一个列表:

Debian/Ubuntu

Python 2

sudo apt install libpq-dev python-dev

Python 3

sudo apt install libpq-dev python3-dev

Additional

If none of the above solve your issue, try

如果以上这些都不能解决你的问题,那就试试吧。

sudo apt install build-essential

or

sudo apt install postgresql-server-dev-all

#2


110  

On CentOS, you need the postgres dev packages:

在CentOS,您需要postgres开发包:

sudo yum install python-devel postgresql-devel

That was the solution on CentOS 6 at least.

这至少是CentOS 6的解决方案。

#3


79  

On Mac Mavericks with Postgres.app version 9.3.2.0 RC2 I needed to use the following code after installing Postgres:

在Mac Mavericks和Postgres。app版本9.3.2.0 RC2安装Postgres后需要使用以下代码:

sudo PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin pip install psycopg2

sudo PATH=$PATH:/应用程序/Postgres.app/内容/版本/9.3/bin pip安装psycopg2。

#4


67  

if you're on a mac you can use homebrew

如果你在mac电脑上,你可以使用自制软件。

brew install postgresql

And all other options are here: http://www.postgresql.org/download/macosx/

所有其他选项都在这里:http://www.postgresql.org/download/macosx/。

Good luck

祝你好运

#5


59  

I recently configured psycopg2 on a windows machine. The easiest install is using a windows executable binary. You can find it at http://stickpeople.com/projects/python/win-psycopg/.

我最近在一台windows机器上配置了psycopg2。最简单的安装是使用windows可执行二进制文件。你可以在http://stickpeople.com/projects/python/win-psycopg/找到它。

To install the native binary in a virtual envrionment, use easy_install:

要在虚拟环境中安装本机二进制文件,请使用easy_install:

C:\virtualenv\Scripts\> activate.bat
(virtualenv) C:\virtualenv\Scripts\> easy_install psycopg2-2.5.win32-py2.7-pg9.2.4-release.exe

#6


27  

For Python 3 you should use sudo apt-get install libpq-dev python3-dev under Debian.

对于Python 3,您应该使用sudo apt-get在Debian下安装libpq-dev python3-dev。

#7


24  

This is what worked for me (On RHEL, CentOS:

这就是我的工作(在RHEL, CentOS:

sudo yum install postgresql postgresql-devel python-devel

And now include the path to your postgresql binary dir with you pip install:

现在,在您的pip安装中包含您的postgresql二进制目录的路径:

sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2

Make sure to include the correct path. Thats all :)

确保包含正确的路径。这是所有:)

UPDATE: For python 3, please install python3-devel instead of python-devel

更新:对于python3,请安装python3-devel而不是python-devel。

#8


21  

If you using Mac OS, you should install PostgreSQL from source. After installation is finished, you need to add this path using:

如果使用Mac OS,则应该从源代码安装PostgreSQL。安装完成后,您需要使用以下方法添加以下路径:

export PATH=/local/pgsql/bin:$PATH

or you can append the path like this:

或者你可以这样添加路径:

export PATH=.../:usr/local/pgsql/bin

in your .profile file or .zshrc file.

在您的.profile文件或.zshrc文件中。

This maybe vary by operating system.

这可能因操作系统而异。

You can follow the installation process from http://www.thegeekstuff.com/2009/04/linux-postgresql-install-and-configure-from-source/

您可以按照安装过程从http://www.thegeekstuff.com/2009/04/linux-postgresql- installandconfigurefrom-source/。

#9


16  

The answers so far are too much like magic recipes. The error that you received tells you that pip cannot find a needed part of the PostgreSQL Query library. Possibly this is because you have it installed in a non-standard place for your OS which is why the message suggests using the --pg-config option.

到目前为止,答案就像魔术食谱一样。您收到的错误告诉您,pip无法找到PostgreSQL查询库所需的部分。这可能是因为您已经将它安装在您的操作系统的非标准位置,这就是为什么消息建议使用-pg-config选项。

But a more common reason is that you don't have libpq installed at all. This commonly happens on machines where you do NOT have PostgreSQL server installed because you only want to run client apps, not the server itself. Each OS/distro is different, for instance on Debian/Ubuntu you need to install libpq-dev. This allows you to compile and link code against the PostgreSQL Query library.

但更常见的原因是,您根本没有安装libpq。这通常发生在您没有安装PostgreSQL服务器的机器上,因为您只希望运行客户机应用程序,而不是服务器本身。每个OS/发行版不同,例如在Debian/Ubuntu上,您需要安装libpq-dev。这允许您在PostgreSQL查询库中编译和链接代码。

Most of the answers also suggest installing a Python dev library. Be careful. If you are only using the default Python installed by your distro, that will work, but if you have a newer version, it could cause problems. If you have built Python on this machine then you already have the dev libraries needed for compiling C/C++ libraries to interface with Python. As long as you are using the correct pip version, the one installed in the same bin folder as the python binary, then you are all set. No need to install the old version.

大多数答案还建议安装Python dev库。小心些而已。如果您只使用发行版所安装的默认Python,那么这将起作用,但是如果您有一个较新的版本,它可能会导致问题。如果您在这台机器上构建了Python,那么您已经有了编译C/ c++库和Python接口所需的开发库。只要您使用的是正确的pip版本,安装在与python二进制文件相同的bin文件夹中,那么您就全部设置好了,不需要安装旧版本。

#10


12  

On Debian/Ubuntu:

在Debian / Ubuntu:

First install and build dependencies of psycopg2 package:

首先安装和构建psycopg2包的依赖项:

# apt-get build-dep python-psycopg2

Then in your virtual environment, compile and install psycopg2 module:

然后在虚拟环境中,编译并安装psycopg2模块:

(env)$ pip install psycopg2

#11


6  

I've done this before where in windows you install first into your base python installation.

我已经在windows中首先安装到您的基础python安装中完成了这一操作。

Then, you manually copy the installed psycopg2 to the virtualenv install.

然后,您手动复制安装的psycopg2到virtualenv安装。

It's not pretty, but it works.

它不漂亮,但很管用。

#12


5  

Besides installing the required packages, I also needed to manually add PostgreSQL bin directory to PATH.
$vi ~/.bash_profile
Add PATH=/usr/pgsql-9.2/bin:$PATH before export PATH.
$source ~/.bash_profile
$pip install psycopg2

除了安装所需的包之外,我还需要手动地将PostgreSQL bin目录添加到PATH中。vi ~ /美元。bash_profile Add PATH=/usr/pgsql-9.2/bin:$PATH在导出路径之前。源~ /美元。bash_profile pip安装psycopg2美元

#13


3  

On windows XP you get this error if postgres is not installed ...

在windows XP上,如果没有安装postgres,就会出现这个错误……

#14


3  

I installed Postgresql92 using the RedHat / CentOS repository on PG's downloads site http://www.postgresql.org/download/linux/redhat/

我在PG的下载网站http://www.postgresql.org/download/linux/redhat/中使用RedHat / CentOS存储库安装了Postgresql92。

To get pg_config, I had to add /usr/pgsql-9.2/bin to PATH.

为了获得pg_config,我必须添加/usr/pgsql-9.2/bin到PATH。

#15


2  

I've been battling with this for days, and have finally figured out how to get the "pip install psycopg2" command to run in a virtualenv in Windows (running Cygwin).

我已经和这个问题斗争了好几天,终于找到了如何让“pip安装psycopg2”命令在Windows(运行Cygwin)的virtualenv中运行。

I was hitting the "pg_config executable not found." error, but I had already downloaded and installed postgres in Windows. It installed in Cygwin as well; running "which pg_config" in Cygwin gave "/usr/bin/pg_config", and running "pg_config" gave sane output -- however the version installed with Cygwin is:

我正在点击“pg_config可执行文件未找到”错误,但我已经在Windows中下载并安装了postgres。它也安装在Cygwin中;在Cygwin中运行的“pg_config”提供了“/usr/bin/pg_config”,运行“pg_config”使输出正常——但是安装了Cygwin的版本是:

VERSION = PostgreSQL 8.2.11

VERSION = PostgreSQL 8.2.11

This won't work with the current version of psycopg2, which appears to require at least 9.1. When I added "c:\Program Files\PostgreSQL\9.2\bin" to my Windows path, the Cygwin pip installer was able to find the correct version of PostgreSQL, and I was able to successfully install the module using pip. (This is probably preferable to using the Cygwin version of PostgreSQL anyway, as the native version will run much quicker).

这与当前的psycopg2版本不兼容,后者似乎至少需要9.1。当我将“c:\程序文件\PostgreSQL\9.2\bin”添加到我的Windows路径时,Cygwin pip安装程序能够找到正确的PostgreSQL版本,并且我能够成功地使用pip安装模块。(这可能比使用PostgreSQL的Cygwin版本更可取,因为本机版本将运行得更快)。

#16


2  

On Fedora 24: For Python 3.x

Fedora 24:用于Python 3.x。

sudo dnf install postgresql-devel python3-devel

sudo dnf install redhat-rpm-config

Activate your Virtual Environment:

激活你的虚拟环境:

pip install psycopg2

#17


1  

For lowly Windows users were stuck having to install psycopg2 from the link below, just install it to whatever Python installation you have setup. It will place the folder named "psycopg2" in the site-packages folder of your python installation.

对于底层的Windows用户,他们不得不从下面的链接安装psycopg2,只需安装到您安装的任何Python安装中。它将把名为“psycopg2”的文件夹放在python安装的站点包文件夹中。

After that, just copy that folder to the site-packages directory of your virtualenv and you will have no problems.

之后,只需将该文件夹复制到virtualenv的站点包目录,就不会出现问题。

here is the link you can find the executable to install psycopg2

这里是链接,您可以找到可执行程序来安装psycopg2。

http://www.lfd.uci.edu/~gohlke/pythonlibs/

http://www.lfd.uci.edu/ gohlke / pythonlibs /

#18


1  

On OpenSUSE 13.2, this fixed it:

在OpenSUSE 13.2上,这是固定的:

sudo zypper in postgresql-devel 

#19


1  

I could install it in a windows machine and using Anaconda/Spyder with python 2.7 through the following commands:

我可以将它安装在windows机器中,并通过以下命令使用python 2.7的Anaconda/Spyder:

 !pip install psycopg2

Then to establish the connection to the database:

然后建立与数据库的连接:

 import psycopg2
 conn = psycopg2.connect(dbname='dbname',host='host_name',port='port_number', user='user_name', password='password')

#20


1  

In Arch base distributions:

在拱基地分布:

sudo pacman -S python-psycopg2
pip2 install psycopg2  # Use pip or pip3 to python3

#21


1  

Psycopg2 Depends on Postgres Libraries. On Ubuntu You can use:

Psycopg2依赖于Postgres库。在Ubuntu上你可以使用:

apt-get install libpq-dev

Then:

然后:

pip install psycopg2

#22


0  

On Ubuntu I just needed the postgres dev package:

在Ubuntu上,我只需要postgres开发包:

sudo apt-get install postgresql-server-dev-all

*Tested in a virtualenv

* virtualenv中进行测试

#23


0  

On OSX 10.11.6 (El Capitan)

osx10.11.6 (El Capitan)

brew install postgresql
PATH=$PATH:/Library/PostgreSQL/9.4/bin pip install psycopg2

#24


0  

On OSX with macports:

在OSX macports:

sudo port install postgresql96
export PATH=/opt/local/lib/postgresql96/bin:$PATH

#25


0  

if pip is not working than you can download .whl file from here https://pypi.python.org/pypi/psycopg2 extract it.. than python setup.py install

如果pip不工作,你可以从这里下载。whl文件,https://pypi.python.org/pypi/psycopg2提取它。比python设置。py安装

#26


-1  

Try this in Gentoo:

在Gentoo试试这个:

emerge dev-libs/libpqxx