PostgreSQL on windows 7 (psycopg2 install problem)

2,117 views
Skip to first unread message

Mustafa Tulu

unread,
Apr 14, 2013, 10:45:46 AM4/14/13
to django...@googlegroups.com
Hi All,

I am very new on the subject. Trying to run a postgresql backend with django. (sqllite3 is said to cause problems)

My google searches do not reveal useful links on how to do it.

I met problems with "pip install psycopg2".

When I try to install the package into my virtualenv in pycharm, it tries to compile the source into binaries, it fails at linking stage, giving errors like:
 Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
    pqpath.obj : error LNK2019: unresolved external symbol _PQclear referenced in function _pq_raise
    connection_int.obj : error LNK2001: unresolved external symbol _PQclear
    cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
    error_type.obj : error LNK2001: unresolved external symbol _PQclear
    pqpath.obj : error LNK2019: unresolved external symbol _PQerrorMessage referenced in function _pq_raise

----

I have also tried to copy the binaries into my virtualenv.

I still get
"Error: No module named psycopg2.extensions" error.

Does anybody have a working solution?

Regards

Serdar Dalgic

unread,
Apr 14, 2013, 12:47:14 PM4/14/13
to django...@googlegroups.com
On Sun, Apr 14, 2013 at 5:45 PM, Mustafa Tulu <musta...@gmail.com> wrote:
> Hi All,

Hi;

>
> When I try to install the package into my virtualenv in pycharm, it tries to
> compile the source into binaries, it fails at linking stage, giving errors
> like:
> Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and
> object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
> pqpath.obj : error LNK2019: unresolved external symbol _PQclear
> referenced in function _pq_raise
> connection_int.obj : error LNK2001: unresolved external symbol _PQclear
> cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
> error_type.obj : error LNK2001: unresolved external symbol _PQclear
> pqpath.obj : error LNK2019: unresolved external symbol _PQerrorMessage
> referenced in function _pq_raise
>

This problem is not django-specific.

Make sure you have python-dev and libpq-dev packages installed on your
environment. After that, try "pip install psycopg2"

--
- Serdar Dalgıç <s...@serdardalgic.org>
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

Sanjay Bhangar

unread,
Apr 14, 2013, 1:29:05 PM4/14/13
to django...@googlegroups.com
On Windows, I'd strongly recommend just installing the pre-compiled binaries for these sort've things, unless you're experienced with compiling software / making this sort've thing work on Windows ..

So, install something like http://www.stickpeople.com/projects/python/win-psycopg/ and then, make sure your virtualenv is configured to use system-site-packages. (if you are using the latest virtualenv, you would need to maybe re-create the virtualenv with "virtualenv --system-site-packages ." .. ) - just google virtualenv system-site-packages if that does not fully make sense :-)

It's probably "better" to use pip and install it inside your virtualenv, but on Windows, I could never figure that out :-), and installing the .exe files and using --system-site-packages seems to work fine for most things .. it should be fairly rare that you require two different versions of something like psycopg2 for different projects, so it should not be problematic to have it installed system-wide ..

All the best,
Sanjay





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Avraham Serour

unread,
Apr 14, 2013, 1:53:00 PM4/14/13
to django...@googlegroups.com
I usually try to compile the packages on my win7 machine, just so I can use pip install inside my virtualenv.
psycopg2 was the only one so far that I couldn't, eventually I installed the pre compiled binaries on my root python installation and then copied the files/folder necessary for psycopg2 from site-packages (from my root python to the virtual env)

Mustafa Tulu

unread,
Apr 14, 2013, 3:10:41 PM4/14/13
to django-users
Thank you! Installing system wide did actually solve the problem.


On Sun, Apr 14, 2013 at 8:29 PM, Sanjay Bhangar <sanjay...@gmail.com> wrote:

Maksym Sokolsky

unread,
Feb 12, 2014, 1:23:55 PM2/12/14
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages