Installing psycopg2 (postgresql) in virtualenv on windows

I installed psycopg2 in virtualenv using easy_install psycopg2. I did not see any errors and looks like installation went fine.. there is an egg file created in the site-packages dir for psycopg2..

but when I run import psycopg2 in the interpreter, I am getting following error.. any clue? How can I fix it.. any other way to install psycopg2 in virtualenv..

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "build\bdist.win32\egg\psycopg2\__init__.py", line 69, in <module> File "build\bdist.win32\egg\psycopg2\_psycopg.py", line 7, in <module> File "build\bdist.win32\egg\psycopg2\_psycopg.py", line 6, in __bootstrap__

Thanks.

-------------Problems Reply------------

Edit: this solution is outdated. Refer to this answer instead.

I had the same problem. Following the suggestion on the download page of the Windows port for getting it working on Zope worked for me under virtualenv (also in the non-virtual install):

  1. Download the executable, rename the .exe extension to .zip
  2. Extract the file contents.
  3. Copy the psycopg2 folder to MyEnv/Lib
  4. Copy the egg to MyEnv/Lib/site-packages

Have you checked that PostgreSQL's 'bin' directory is on the system path? Check with a quick typing of 'set' and see what you get.

This is the most common cause of import failures of psycopg2 on Windows.

There is an alternative to install python packages in your computer i.e, pip . You can download python packages by just executing:-

pip install pyscopg2

The general format of the command is

pip install [package-name]

P.S:- To install python packages globally through pip

sudo pip install [package-name]

Category:python Views:4 Time:2010-06-13

Related post

  • How do I install psycopg2 in a virtualenv that seems to not have gcc access? 2011-03-25

    I'm trying to install psycopg2 in a virtualenv but it seems that I don't have access to gcc. Is there a way to activate gcc from inside the virtualenv? If not, is there any other library that works with PostgreSQL that does not use gcc? My attempt to

  • Can not pip install PIL in a virtualenv in Windows because of Warning and ValueError 2012-04-26

    I am trying to install PIL in a virtualenv but have failed. I created a brand new virtualenv and did pip install PIL and got the following C:\Users\s3z\Desktop\My Dropbox\pythons\ham>Scripts\activate (ham) C:\Users\s3z\Desktop\My Dropbox\pythons\h

  • Installing psycopg2 in virtualenv (Ubuntu 10.04, Python 2.5) 2010-10-02

    I had problems installing psycopg2 in a virtualenv. I tried different things explained there: http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/ The last thing I tried is this... I created a virtualenv with -p python2.5 -

  • How to install psycopg2 on clean OS X Lion with Xcode 4.1 2011-07-28

    On a clean OS X Lion with Xcode 4.1 installed. PostgreSQL is already installed by Apple. I installed Django 1.3. The instruction for installing psycopg2 isn't clear. Any help is appreciated. --------------Solutions------------- Try this to install ps

  • Can't install psycopg2 in virtualenv "error: stdarg.h: No such file or directory" 2012-04-26

    NOTE: This same error also occurs when using easy_install, other ways of installation... I'm facing almost exactly the same problem as I'm trying to install psycopg2 onto Mac OS 10.6.3; it claims it can't find "stdarg.h" but I can see it's there; wha

  • VirtualEnv on Windows, pip fails to install packages with C-extensions 2012-02-13

    I'm trying to modernize a little, but for whatever reason pip fails to install anything with a C-extension. The nasty offenders being MySQLdb, PIL, Fabric. I can install them with exe's, but modern requirements techniques won't work. For example, her

  • I'm trying to install psycopg2 onto Mac OS 10.6.3; it claims it can't find "stdarg.h" but I can see it's there; what should I do? 2010-06-15

    I'm desperately trying to successfully install psycopg2 but keep running into errors. The latest one seems to involve it not being to find "stdarg.h" (see code below). However I can see with my own eyes that a file called stdarg.h exists at /Develope

  • Help Installing psycopg2 on snow leopard : command '/usr/bin/gcc-4.0' failed with exit status 1 2010-08-12

    This has been driving me crazy for 2 days. I have been trying to install psycopg2 using easy_install and no matter what I try (i.e using gcc-4.0 instead of the snow leopard default one) I always get the same error: error: Setup script exited with err

  • How to access Postgresql using Qt in Windows 2009-03-16

    I am developing an application using QtRuby and PostgreSQL. I successfully developed and running successfully in Linux. Now i want to run the same application in windows. But I am failing to connect to database(postgresql). I am getting the following

  • On a Mac w/ Python2.6 and trying to install psycopg2 2009-09-03

    I am new to Python. I have Python2.6 running now. I am following the Tutorial on the Python site. My question is when I try to follow the instructions here: http://py-psycopg.darwinports.com/ I get something like... sudo port install py-psycopg ... b

  • Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` 2010-07-27

    Possible Duplicate: How to handle Ruby on Rails error: “Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'” I'm trying to get Redmine working with postgres. In my logs I keep seeing. Please install the postgresql ada

  • Trouble installing psycopg2 on CentOS 2011-01-27

    I'm trying to install psycopg2 on CentOS, I followed everything on this tutorial from "On with it: Installing Python 2.6" all the way to when it imports psycopg2, but when I try to import I get the following error: Traceback (most recent call last):

  • Cannot install psycopg2 on OSX 10.6.7 with XCode4 2011-03-25

    Trying to install psycopg2 on OSX results in the following: building 'psycopg2._psycopg' extension creating build/temp.macosx-10.6-universal-2.6 creating build/temp.macosx-10.6-universal-2.6/psycopg gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -

  • How to install numpy in a virtualenv on Debian? 2011-06-23

    (NB: see this other post for why I am not using dpkg/apt-get/etc. for this installation.) I can install numpy in a virtualenv on Debian with, e.g., pip: (base)[1778]% pip -v install numpy Downloading/unpacking numpy ... <output omitted> ... Suc

  • Error installing psycopg2 in cygwin 2011-10-03

    I'm trying to install psycopg2 in cygwin but have not succeeded yet. The error is:- [email protected] ~/FieldAgentWeb/FieldAgentWeb $ easy_install psycopg2 Searching for psycopg2 Reading http://pypi.python.org/simple/psycopg2/ Reading http://initd.org/

  • Error installing psycopg2 on Mac OS 10.6 2011-12-06

    Hi i am trying to install psycopg2 on Mac 10.6. After i install i get this error when i try to import import psycopg2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Python/2.6/site-packages/psycopg2/

  • Installing a python/sphinx environment on windows? 2011-12-08

    We use Sphinx for documentation within our Linux/OSX python environment, but we have someone on Windows who would like to be able to get an environment in which they can edit and build the Sphinx documentation. Is it possible to set up Sphinx on wind

  • how to install psycopg2 on OSX 10.7 2011-12-18

    I followed the following procedure: 1) $ sudo pip install psycopg2 This gave me the following error Downloading/unpacking psycopg2 Running setup.py egg_info for package psycopg2 no previously-included directories found matching 'doc/src/_build' Insta

  • virtualenv on windows 7 returns AssertionError 2011-12-31

    Having trouble with virtualenv on Windows 7. I run: virtualenv _testenv It returns: Traceback (most recent call last): File "C:\Python27\Scripts\virtualenv-script.py", line 9, in <module> load_entry_point('virtualenv==1.5.2', 'console_scripts',

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.192 (s). 11 q(s)