8

Hi I am getting this error while I am trying to run syncdb in my virtual environment.

If I copy psycopg2 folder to my project folder (where I have my manage.py and settings.py) then this error disappears. But I still get this error when the code is pushed to heroku.

I have referred to many online materials but wasn't very lucky.

File "c:\Users\mayayadav\anteus\venv\lib\site-packages\psycopg2-2.4.5-py2.7-wi
  n32.egg\psycopg2\__init__.py", line 67, in <module>
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: DLL load failed: The specified module could not be found. (venv)
3
  • Have you installed the PostgreSQL client library? Oct 7, 2012 at 3:22
  • 1
    Yes I did, i have installed psycopg from initd.org/psycopg and did an "easy_install psycopg2". Its still not working, is there any other lib i should be using ?
    – Mayank
    Oct 8, 2012 at 18:15
  • The PostgreSQL client library, which the DB-API adapter (which you have installed) uses to talk to the database server. Oct 8, 2012 at 18:43

4 Answers 4

15

I had the same problem on Windows, The way i get it working was to install psycopg2 from:

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

And doing it this way it's recomended here http://initd.org/psycopg/install/

2
  • Note that the particularly important part of this for VirtualEnv's can be found below the Windows installer download: Do not double-click the package to run. Instead, use easy_install to execute the .exe from within your activated virtualenvironment.
    – Chaffelson
    Sep 17, 2015 at 10:00
  • 1
    be sure to choose the 32 bit version or he 64 bit version according to your system on the stickpeople website
    – M.C.
    Mar 30, 2016 at 13:52
12

In the case, where the install binaries are not up to date (as it happened today: latest Python is 3.4 and PostgresSQL - 9.3, while latest avaiable are 3.3 and 9.2.6 respectively), it is enough to add the PostgresSQL binary path (e.g. C:\Program Files\PostgreSQL\9.3\bin) to the path variable.

Note: you need to restart your command line to get it working.

2
  • This tip worked for me. I'm on Windows 8 64 bits Brazilian Portuguese, Enthought Canopy Python 2.7.6 64-bit, Postgres 9.3 with Postgis enabled. I installed both psycopg2 and ppygis with pip install.
    – srodriguex
    Jul 21, 2014 at 4:08
  • I updated windows path to include Postgres bin folder. But had to restart command line to get it working was what I needed!
    – curtisp
    Nov 9, 2015 at 7:08
6

2019 Update

I encountered the same issue with Python 3.8 and psycopg2 2.8.3 and 2.8.4. Apparently psycopg2 doesn't work with Python 3.8 yet (understandably, since 3.8 released very recently). The fix for me was to go back to using Python 3.7.

1
  • I ran pip install psycopg2-binary and it worked for me
    – Saber
    Aug 3, 2020 at 5:23
2

It's so old problem... I ran into a problem with PyCharm and virtualenv, PyCharm have problem with pip install psycopg2. I copied _psycopg.cp38-win_amd64.pyd from global python to \venv\Lib\site-packages\psycopg2. And all done.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.