5

I am trying the following command on Windows 7 using powershell

pip install psycopg2

And i am getting an error:

error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat). Command "C:\Users\Piyush\AppData\Local\Programs\Python\Python35\python.exe -c "import setuptools, tokenize;file='C:\Users\Piyush\AppData\Local\Temp\pip-build-qe38dwoj\psycopg2\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\Piyush\AppData\Local\Temp\pip-7bjug79j-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Piyush\AppData\Local\Temp\pip-build-qe38dwoj\psycopg2

To intall Visuall C++, it requires Visual Studio to be installed. Except for installing Visual Studio 2013. Is there any other, that I can install Psycopg2 for Python 3.5??

Community
  • 1
  • 1
Piyush aggarwal
  • 750
  • 2
  • 14
  • 25
  • 2
    Python 3.5 is alpha version, but you can download the Python 3.4 precompiled binary from http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg – Selcuk Feb 19 '15 at 16:41

5 Answers5

11

Try this one. It worked for me

I Visited the http://www.lfd.uci.edu/~gohlke/pythonlibs/ and downloaded psycopg2-2.6.1-cp35-none-win32.whl file and copied it on C:\

later I activated my Virualenv by running this C:\mydjango\django19\Scripts\activate on the cmd which resulted to this (django19) C:/> and ran the following pip command, pip install psycopg2-2.6.1-cp35-none-win32.whl and the installation was successful.

Note: Run the pip install psycopg2.......whl when you are in the current folder that has the psycopg2-2.6.1-cp35-none-win32.whl file via cmd

Bryan Kimani
  • 921
  • 7
  • 11
  • Same trouble, PyCharm 2016, Python 3.5. Tried this solution. The import still didn't work, pressed "install package" in the IDE, and then the installation went smooth :) – kit May 19 '16 at 20:59
8

I ran into a similar issue on Windows. I had to install a compiled version of it and then easy_install it.

You can find a compiled version of psycopg2 here: http://www.lfd.uci.edu/~gohlke/pythonlibs/

And then do easy_install C:/locaiton/of/download.exe

That's what I do to install it on my Windows machine.

deef
  • 4,410
  • 2
  • 17
  • 21
1

For Linux/Mac based you need to first install:

sudo apt-get install python3-dev

and then install psycopg2:

pip install psycopg2

For me it worked in DigitalOcean Linux 16.04 Production server

Let me know if anyone got this correct!

Dinesh Sunny
  • 4,663
  • 3
  • 30
  • 29
0

on Mac first

brew install postgresql

and then

pip install psycopg2
Areza
  • 5,623
  • 7
  • 48
  • 79
0

In my case this error was occurring because the python path was not in environment variable. You can verify by typing python/python3 in your cmd and if the python shell is starting or not.

These different methods also worked for me at different times:

  • check python path in environment variable.
  • installing visual c++ 14 or latest.
  • reinstalling python.
  • installing binary or psycopg2 instead.
  • install via easy_install.
  • check by installing in global environment instead of virtual environment.
  • try different psycopg2 version whl file. https://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg
bihari_gamer
  • 422
  • 5
  • 15