Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Psycopg installation on windows

I am trying to install psycopg2 under Windows (Windows 7, 64 bit). I am using Python 2.7.2 from Python(x,y) and PostgreSQL 9.2.1 .

My first try was using the windows port that is downloadable from http://www.stickpeople.com/projects/python/win-psycopg/ (psycopg2-2.4.5.win-amd64-py2.7-pg9.1.3-release.exe). I get a message then that

Python 2.7 required but was not found in the registry

In the next dialogue it does not allow me to choose any python installations. All other programs and installations find my python happily.

This being failed, I tried to use the source package directly from http://pypi.python.org/pypi/psycopg2 but after trying:

python setup.py install

I am now stuck with the error message:

error: Unable to find vcvarsall.bat

Does anybody have an idea how to solve this?

like image 276
Markus M. Avatar asked Nov 01 '12 05:11

Markus M.


Video Answer


2 Answers

You're using a different Python distribution to the one the psycopg2 installer expects, so it cannot find the Python install location.

You can manually install psycopg2 from the binaries you downloaded by following the instructions on the psycopg2 download page for issues installing with Zope, which read:

It has been noted that the the installers for psycopg2 will not find the zope installation of python, stop the installation, and not installing psycopg2. A work around is to extract the files by renaming the extension from *.exe to *.zip and using a zip extractor (such as WinZip/PkZip/7z) to extract the psycopg2 folder and place it at \lib\python. I do not use Zope, so I will not be able to provide support or instructions on how to use it. Let me know if it does not work, though.

The same will apply to the Python(x,y) distribution that you are using. Unzip the psycopg2 installer .exe using 7-zip, then copy the psycopg2 folder and 'psycopg2-2.5.2-py2.7.egg-info' file (so 'psycopg2' will apear on 'pip freeze') into your Python lib\site-packages directory. See installing Python modules.

You should then be able to import psycopg2.

like image 90
Craig Ringer Avatar answered Oct 16 '22 20:10

Craig Ringer


  1. Choose the appropriate version from this page:

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

  2. Right click and select copy link address

  3. Back at home, use easy_install <<Paste URL Here>>

  4. Freeze your new requirements: pip freeze > requirements.txt

like image 27
Adam Starrh Avatar answered Oct 16 '22 19:10

Adam Starrh