我已经阅读了几个关于此的链接。
如果我尝试使用python port for windows:我使用的是python 3.4,那么就失败了。
同时下载档案+" setup.py install"或者" pip install pyscopg2"我得到了以下错误。我安装了visual studio 2012,我安装了一个2010版本来摆脱"找不到vcvarsall.bat"
错误:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python34\libs /LIBPATH:C:\Python34\PCbuild /LIBPATH:C:/PROGRA~1/POSTGR~1/9.3/lib ws2_32.lib advapi32.lib secur32.lib libpq.lib shfolder.lib build\temp.win32-3.4\Release\psycopg\psycopgmodule.obj build\temp.win32-3.4\Release\psycopg\green.obj build\temp.win32-3.4\Release\psycopg\pqpath.obj build\temp.win32-3.4\Release\psycopg\utils.obj build\temp.win32-3.4\Release\psycopg\bytes_format.obj build\temp.win32-3.4\Release\psycopg\connection_int.obj build\temp.win32-3.4\Release\psycopg\connection_type.obj build\temp.win32-3.4\Release\psycopg\cursor_int.obj build\temp.win32-3.4\Release\psycopg\cursor_type.obj build\temp.win32-3.4\Release\psycopg\diagnostics_type.obj build\temp.win32-3.4\Release\psycopg\error_type.obj build\temp.win32-3.4\Release\psycopg\lobject_int.obj build\temp.win32-3.4\Release\psycopg\lobject_type.obj build\temp.win32-3.4\Release\psycopg\notify_type.obj build\temp.
win32-3.4\Release\psycopg\xid_type.obj build\temp.win32-3.4\Release\psycopg\adapter_asis.obj build\temp.win32-3.4\Release\psycopg\adapter_binary.obj build\temp.win32-3.4\Release\psycopg\adapter_datetime.obj build\temp.win32-3.4\Release\psycopg\adapter_list.obj build\temp.win32-3.4\Release\psycopg\adapter_pboolean.obj build\temp.win32-3.4\Release\psycopg\adapter_pdecimal.obj build\temp.win32-3.4\Release\psycopg\adapter_pint.obj build\temp.win32-3.4\Release\psycopg\adapter_pfloat.obj build\temp.win32-3.4\Release\psycopg\adapter_qstring.obj build\temp.win32-3.4\Release\psycopg\microprotocols.obj build\temp.win32-3.4\Release\psycopg\microprotocols_proto.obj build\temp.win32-3.4\Release\psycopg\typecast.obj /OUT:build\lib.win32-3.4\psycopg2\_psycopg.pyd /IMPLIB:build\temp.win32-3.4\Release\psycopg\_psycopg.lib /MANIFESTFILE:build\temp.win32-3.4\Release\psycopg\_psycopg.pyd.manifest
Creating library build\temp.win32-3.4\Release\psycopg\_psycopg.lib and object build\temp.win32-3.4\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
connection_int.obj : error LNK2001: unresolved external symbol _PQerrorMessage
lobject_int.obj : error LNK2001: unresolved external symbol _PQerrorMessage
pqpath.obj : error LNK2019: unresolved external symbol _PQresultErrorField referenced in function _pq_raise
diagnostics_type.obj : error LNK2001: unresolved external symbol _PQresultErrorField
pqpath.obj : error LNK2019: unresolved external symbol _PQresultErrorMessage referenced in function _pq_raise
pqpath.obj : error LNK2019: unresolved external symbol _PQstatus referenced in function _pq_raise
connection_int.obj : error LNK2001: unresolved external symbol _PQstatus
pqpath.obj : error LNK2019: unresolved external symbol _PQgetResult referenced in function _pq_clear_async
pqpath.obj : error LNK2019: unresolved external symbol _PQsetnonblocking referenced in function _pq_set_non_blocking
pqpath.obj : error LNK2019: unresolved external symbol _PQresultStatus referenced in function _pq_execute_command_locked
connection_int.obj : error LNK2001: unresolved external symbol _PQresultStatus
pqpath.obj : error LNK2019: unresolved external symbol _PQexec referenced in function _pq_execute_command_locked
pqpath.obj : error LNK2019: unresolved external symbol _PQgetvalue referenced in function _pq_get_guc_locked
cursor_type.obj : error LNK2001: unresolved external symbol _PQgetvalue
pqpath.obj : error LNK2019: unresolved external symbol _PQisBusy referenced in function _pq_is_busy
pqpath.obj : error LNK2019: unresolved external symbol _PQconsumeInput referenced in function _pq_is_busy
pqpath.obj : error LNK2019: unresolved external symbol _PQflush referenced in function _pq_flush
connection_int.obj : error LNK2001: unresolved external symbol _PQflush
pqpath.obj : error LNK2019: unresolved external symbol _PQsendQuery referenced in function _pq_send_query
pqpath.obj : error LNK2019: unresolved external symbol _PQfname referenced in function __pq_fetch_tuples
pqpath.obj : error LNK2019: unresolved external symbol _PQfmod referenced in function __pq_fetch_tuples
pqpath.obj : error LNK2019: unresolved external symbol _PQfsize referenced in function __pq_fetch_tuples
pqpath.obj : error LNK2019: unresolved external symbol _PQftype referenced in function __pq_fetch_tuples
pqpath.obj : error LNK2019: unresolved external symbol _PQbinaryTuples referenced in function __pq_fetch_tuples
pqpath.obj : error LNK2019: unresolved external symbol _PQnfields referenced in function __pq_fetch_tuples
cursor_type.obj : error LNK2001: unresolved external symbol _PQnfields
pqpath.obj : error LNK2019: unresolved external symbol _PQputCopyEnd referenced in function __pq_copy_in_v3
pqpath.obj : error LNK2019: unresolved external symbol _PQputCopyData referenced in function __pq_copy_in_v3
pqpath.obj : error LNK2019: unresolved external symbol _PQfreemem referenced in function __pq_copy_out_v3
connection_int.obj : error LNK2001: unresolved external symbol _PQfreemem
adapter_binary.obj : error LNK2001: unresolved external symbol _PQfreemem
pqpath.obj : error LNK2019: unresolved external symbol _PQgetCopyData referenced in function __pq_copy_out_v3
pqpath.obj : error LNK2019: unresolved external symbol _PQntuples referenced in function _pq_fetch
pqpath.obj : error LNK2019: unresolved external symbol _PQoidValue referenced in function _pq_fetch
pqpath.obj : error LNK2019: unresolved external symbol _PQcmdTuples referenced in function _pq_fetch
pqpath.obj : error LNK2019: unresolved external symbol _PQcmdStatus referenced in function _pq_fetch
pqpath.obj : error LNK2019: unresolved external symbol _PQresStatus referenced in function _pq_fetch
utils.obj : error LNK2019: unresolved external symbol _PQescapeString referenced in function _psycopg_escape_string
utils.obj : error LNK2019: unresolved external symbol _PQescapeStringConn referenced in function _psycopg_escape_string
connection_int.obj : error LNK2019: unresolved external symbol _PQnotifies referenced in function _conn_notifies_process
connection_int.obj : error LNK2019: unresolved external symbol _PQparameterStatus referenced in function _conn_get_standard_conforming_strings
connection_type.obj : error LNK2001: unresolved external symbol _PQparameterStatus
connection_int.obj : error LNK2019: unresolved external symbol _PQprotocolVersion referenced in function _conn_get_protocol_version
connection_int.obj : error LNK2019: unresolved external symbol _PQserverVersion referenced in function _conn_get_server_version
connection_int.obj : error LNK2019: unresolved external symbol _PQgetCancel referenced in function _conn_setup_cancel
connection_int.obj : error LNK2019: unresolved external symbol _PQfreeCancel referenced in function _conn_setup_cancel
connection_type.obj : error LNK2001: unresolved external symbol _PQfreeCancel
connection_int.obj : error LNK2019: unresolved external symbol _PQsetNoticeProcessor referenced in function __conn_sync_connect
connection_int.obj : error LNK2019: unresolved external symbol _PQconnectStart referenced in function __conn_sync_connect
connection_int.obj : error LNK2019: unresolved external symbol _PQconnectdb referenced in function __conn_sync_connect
connection_int.obj : error LNK2019: unresolved external symbol _PQconnectPoll referenced in function __conn_poll_connecting
connection_int.obj : error LNK2019: unresolved external symbol _PQfinish referenced in function _conn_close_locked
connection_type.obj : error LNK2019: unresolved external symbol _PQtransactionStatus referenced in function _psyco_conn_get_transaction_status
connection_type.obj : error LNK2019: unresolved external symbol _PQbackendPID referenced in function _psyco_conn_get_backend_pid
connection_type.obj : error LNK2019: unresolved external symbol _PQsocket referenced in function _psyco_conn_fileno
connection_type.obj : error LNK2019: unresolved external symbol _PQcancel referenced in function _psyco_conn_cancel
cursor_type.obj : error LNK2019: unresolved external symbol _PQgetlength referenced in function __psyco_curs_buildrow_fill
cursor_type.obj : error LNK2019: unresolved external symbol _PQgetisnull referenced in function __psyco_curs_buildrow_fill
lobject_int.obj : error LNK2019: unresolved external symbol _lo_open referenced in function _lobject_open
lobject_int.obj : error LNK2019: unresolved external symbol _lo_creat referenced in function _lobject_open
lobject_int.obj : error LNK2019: unresolved external symbol _lo_create referenced in function _lobject_open
lobject_int.obj : error LNK2019: unresolved external symbol _lo_import referenced in function _lobject_open
lobject_int.obj : error LNK2019: unresolved external symbol _lo_close referenced in function _lobject_close_locked
lobject_int.obj : error LNK2019: unresolved external symbol _lo_unlink referenced in function _lobject_unlink
lobject_int.obj : error LNK2019: unresolved external symbol _lo_write referenced in function _lobject_write
lobject_int.obj : error LNK2019: unresolved external symbol _lo_read referenced in function _lobject_read
lobject_int.obj : error LNK2019: unresolved external symbol _lo_lseek referenced in function _lobject_seek
lobject_int.obj : error LNK2019: unresolved external symbol _lo_tell referenced in function _lobject_tell
lobject_int.obj : error LNK2019: unresolved external symbol _lo_export referenced in function _lobject_export
lobject_int.obj : error LNK2019: unresolved external symbol _lo_truncate referenced in function _lobject_truncate
adapter_binary.obj : error LNK2019: unresolved external symbol _PQescapeBytea referenced in function _binary_escape
adapter_binary.obj : error LNK2019: unresolved external symbol _PQescapeByteaConn referenced in function _binary_escape
build\lib.win32-3.4\psycopg2\_psycopg.pyd : fatal error LNK1120: 62 unresolved externals
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe"' failed with exit status 1120
我尝试添加' lib'和'包括' postregsql目录将路径安装到我的路径中。实际上,缺少符号似乎都在那里定义(libpq.obj / c / h)!开始了一个新的' cmd',但结果相同。
答案 0 :(得分:5)
我们最终通过pip使用二进制文件 - > https://github.com/nwcell/psycopg2-windows通过python 3.4
pip install git+https://github.com/nwcell/psycopg2-windows.git@win64-py34#egg=psycopg2
如本帖所述,http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg也是一个很好的资源,但第一个解决方案解决了我的问题。
答案 1 :(得分:0)
我找不到任何用于Windows 64位和python 3.4的psycopg2的二进制文件。我建议你降级到python 3.3并使用在下面地址找到的正确二进制文件。
如果您使用的是virtualenv,则需要激活它并使用easy_install来安装二进制文件。
这样:easy_install http://www.stickpeople.com/projects/python/win-psycopg/2.5.2/psycopg2-2.5.2.win-amd64-py3.3-pg9.2.6-release.exe
编辑:您可以尝试3.4 64位http://www.lfd.uci.edu/~gohlke/pythonlibs/
答案 2 :(得分:0)
解决了同样的问题。我必须从Christoph Gohlke的非官方Windows二进制文件(http://www.lfd.uci.edu/~gohlke/pythonlibs/#psychopy)下载二进制文件,然后使用wheel
进行安装。
请注意,即使您在64位计算机上运行,如果win_amd64不起作用,您也可以尝试使用win32版本。
要使用wheel
安装下载的* .whl(在此处解决:https://stackoverflow.com/a/27909082/4650346),您只需
pip install wheel
然后:
pip install psycopg2‑2.5.5‑cp34‑none‑win32.whl
它也非常适用于virtualenv。