Jaime
Jaime

Reputation: 61

ImportRrror: no module named 'psycopg2'

I'm attempting to use PostgreSQL as my data base and I'm running into an issue when I try to start my server. Here's what I'm doing:

I'm using python 3.4.

Adding pip freeze output as requested:

Django==1.8.4
psycopg2==2.5.2
wheel==0.24.0

when I run the server using the default sqlite3 db I have no issue; it runs fine. As soon as I switch over to postgres I get the following error: ImportError: no module named psycopg2.

pip install psycopg2 wasn't working so I installed psycopg2 from github using this command: pip install git+https://github.com/nwcell/psycopg2-windows.git@win64-py34#egg=psycopg2

Guidance is greatly appreciated.

Upvotes: 0

Views: 4192

Answers (3)

demonno
demonno

Reputation: 524

It is important to specify operating system you are on, as I guess from comment you are using windows.

On windows if you do not wont to install Visual C++ libraries you can just download whl file of the package.

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

choose correct architecture and python version for you and run

pip install path/to/packagename.whl

make sure you are using pip version 6 or newer

Upvotes: 1

gamer
gamer

Reputation: 5863

Before you install psycopg2 please isntall sudo apt-get build-dep python-psycopg2

Upvotes: -1

brainless coder
brainless coder

Reputation: 6430

Seems like you are in Windows. For windows, you need to download and install from the binary files. You can download the installers from here.

http://www.stickpeople.com/projects/python/win-psycopg/

Make sure you select the correct file based on architecture and python version.

After installing the psycopg2 with the installers, re-create your virtual environments to have the plugin working.

Alternatively you can download and install C++ re-distributables from msdn download centre and then try with pip install psycopg2

Upvotes: 1

Related Questions