Mille Bii
Mille Bii

Reputation: 195

psycopg2 install for two versions of python

I have a fresh debian install with :
+ default 2.6.6 python installed
+ also installed python3 at /opt/python3/
+ installed psycopg2

Problem :
>>> import psycopg2
works with standard python
but not the alternate 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.

Upvotes: 0

Views: 2928

Answers (3)

campervancoder
campervancoder

Reputation: 1629

I had the same issue and installing the python3 include files sorted the issue (while in the active virtualenv)

sudo apt-get install python3-dev as per solution provided in this post

Psycopg2 fails to install on python 3 with pip issuing a fatal error

Upvotes: 1

Mille Bii
Mille Bii

Reputation: 195

So I recap for the record and any one stumbing on this
1. Install 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
3. enjoy > pip-3.3 install psycopg2

Upvotes: 0

Martijn Pieters
Martijn Pieters

Reputation: 1121206

You need to install psycopg2 separately for your Python 3 installation.

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).

You cannot reuse the system-installed psycopg2 because that'll only work on Python 2.

Upvotes: 1

Related Questions