[英]psycopg2 install for two versions of python
I have a fresh debian install with : 我有一个新的debian安装:
+ default 2.6.6 python installed +默认安装2.6.6 python
+ also installed python3 at /opt/python3/
+还在
/opt/python3/
安装了python3
+ installed psycopg2 +已安装psycopg2
Problem : 问题:
>>> import psycopg2
works with standard python
适用于标准
python
but not the alternate python /opt/python3/bin/python3
. 但不是备用的python
/opt/python3/bin/python3
。
I presume it is an import path problem, but I don't know how to solve it being a newbie on python. 我认为这是一个导入路径问题,但我不知道如何解决它作为python上的新手。
You need to install psycopg2
separately for your Python 3 installation. 您需要为Python 3安装单独安装
psycopg2
。
You need to follow the installation instructions for installing from source , using pip
or easy_install
will be easiest (provided you have the libpq-dev
debian package installed). 您需要按照安装说明从源代码安装 ,使用
pip
或easy_install
将是最简单的(如果您安装了libpq-dev
debian软件包)。
You cannot reuse the system-installed psycopg2
because that'll only work on Python 2. 你不能重用系统安装的
psycopg2
因为它只适用于Python 2。
I had the same issue and installing the python3 include files sorted the issue (while in the active virtualenv) 我有同样的问题,安装python3包含文件排序问题(在活动的virtualenv)
sudo apt-get install python3-dev
as per solution provided in this post sudo apt-get install python3-dev
按照本文提供的解决方案
Psycopg2 fails to install on python 3 with pip issuing a fatal error Psycopg2无法在python 3上安装,pip发出致命错误
So I recap for the record and any one stumbing on this 所以我回顾一下这个记录和任何一个令人讨厌的事情
1. Install virtualenv. 1.安装virtualenv。 instructions here
这里的说明
2. Install pip for your version, in my case it was pip-3.3 instructions here in order to get distribute_setup.py
and get-pip.py
2.为你的版本安装pip,在我的例子中,这是pip-3.3 指令 ,以获得
distribute_setup.py
和get-pip.py
3. enjoy > pip-3.3 install psycopg2
3.享受
> pip-3.3 install psycopg2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.