我有一个新的debian安装:
+默认安装2.6.6 python
+还在/opt/python3/
上安装了python3
+已安装psycopg2
问题:
>>> import psycopg2
使用标准python
但不是备用python /opt/python3/bin/python3
我认为这是一个导入路径问题,但我不知道如何解决它作为python上的新手。
答案 0 :(得分:1)
您需要为Python 3安装单独安装psycopg2
。
您需要关注installation instructions for installing from source,使用pip
或easy_install
最简单(只要您安装了libpq-dev
debian软件包)。
你无法重用系统安装的psycopg2
,因为它只适用于Python 2.
答案 1 :(得分:1)
我遇到了同样的问题并安装了python3包含文件排序问题(在活跃的virtualenv中)
sudo apt-get install python3-dev
根据此帖提供的解决方案
Psycopg2 fails to install on python 3 with pip issuing a fatal error
答案 2 :(得分:0)
所以我回顾一下这个记录,并且任何一个人都对此感到厌烦
1.安装virtualenv。 instructions here
2.为您的版本安装pip,在我的情况下,它是pip-3.3 instructions here以获得distribute_setup.py
和get-pip.py
3.享受> pip-3.3 install psycopg2