How to easy_install psycopg2 on windows 7?

2019-07-25 12:08发布

问题:

While following this tutorial to setup osqa. I got into the line direct you to run:

easy_install.exe psycopg2

I had located vcvarsall.bat under C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC and added the full path of it to %PATH% but still get the following error:

error: Setup script exited with error: Unable to find vcvarsall.bat

Here is the full cmd output:

C:\>easy_install.exe psycopg2
Searching for psycopg2
Reading https://pypi.python.org/simple/psycopg2/
Reading http://initd.org/projects/psycopg2
Best match: psycopg2 2.5.3
Downloading https://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.5.3.ta
r.gz#md5=09dcec70f623a9ef774f1aef75690995
Processing psycopg2-2.5.3.tar.gz
Writing c:\users\root\appdata\local\temp\easy_install-d3odyl\psycopg2-2.5.3\se
tup.cfg
Running psycopg2-2.5.3\setup.py -q bdist_egg --dist-dir c:\users\root\appdata\
local\temp\easy_install-d3odyl\psycopg2-2.5.3\egg-dist-tmp-lmlmsb
error: Setup script exited with error: Unable to find vcvarsall.bat

Where easy_install try to find the vcvarsall.bat ?

回答1:

Download the binary installer and use that.

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

Windows is a huge pain for software installation from source code. Unless you're already set up with a development environment, just use the binary installer.

It's a pity that easy_install, pip, etc don't do this automatically.



回答2:

Save yourself some grief and download it from this website where you'll find compiled installers for many Python libraries for Windows. I highly recommend bookmarking this if you are using Python on Windows.

Make sure you download the correct one for the version of Python you are using. These installers work with the official Python installer (from python.org), as they read the registry value for the installer location and do the rest of the magic.

As these are Windows installer packages, just double click and follow the prompts.



回答3:

In simple terms,

  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