pip install psycopg2 == 2.7.3失败,退出状态为1120

时间:2019-06-13 13:12:40

标签: python cmd psycopg2

当我运行'pip install psycopg2 == 2.7.3'时,它基本上会爆炸并显示错误代码1,并退出状态1120。我在Windows 10上,茫然无措,因为我什至无法解析此错误信息。任何帮助将不胜感激。

我相信PATH设置正确,我试图获取mod_wsgi,因为有人说它有助于退出代码1120,但实际上在尝试安装该代码时也会遇到相同的错误。

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\Hostx86\x86>pip install psycopg2==2.7.3
Collecting psycopg2==2.7.3
  Using cached https://files.pythonhosted.org/packages/98/99/33ca02c4bc3ed1bd9ceab5614bda2e6d1d31e61ec58345b9feece238c38a/psycopg2-2.7.3.tar.gz
Installing collected packages: psycopg2
  Found existing installation: psycopg2 2.8.2
    Uninstalling psycopg2-2.8.2:
      Successfully uninstalled psycopg2-2.8.2
  Running setup.py install for psycopg2 ... error
    ERROR: Complete output from command 'c:\users\gehri\appdata\local\programs\python\python37-32\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\gehri\\AppData\\Local\\Temp\\pip-install-2kq90f3y\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\gehri\AppData\Local\Temp\pip-record-giee18ni\install-record.txt' --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
[...................................]
    lobject_int.obj : error LNK2001: unresolved external symbol _lo_close
    adapter_binary.obj : error LNK2001: unresolved external symbol _PQescapeByteaConn
    adapter_binary.obj : error LNK2001: unresolved external symbol _PQescapeBytea
    build\lib.win32-3.7\psycopg2\_psycopg.cp37-win32.pyd : fatal error LNK1120: 68 unresolved externals
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x86\\link.exe' failed with exit status 1120
    ----------------------------------------
  Rolling back uninstall of psycopg2
  Moving to c:\users\gehri\appdata\local\programs\python\python37-32\lib\site-packages\psycopg2-2.8.2.dist-info\
   from c:\users\gehri\appdata\local\programs\python\python37-32\lib\site-packages\~sycopg2-2.8.2.dist-info
  Moving to c:\users\gehri\appdata\local\programs\python\python37-32\lib\site-packages\psycopg2\
   from c:\users\gehri\appdata\local\programs\python\python37-32\lib\site-packages\~sycopg2
ERROR: Command "'c:\users\gehri\appdata\local\programs\python\python37-32\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\gehri\\AppData\\Local\\Temp\\pip-install-2kq90f3y\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\gehri\AppData\Local\Temp\pip-record-giee18ni\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\gehri\AppData\Local\Temp\pip-install-2kq90f3y\psycopg2\

更多参考,我在Windows 10中运行,并以管理员身份运行命令提示符。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,只需安装适当版本的python(64位而不是32位)即可解决。

如果您的PC是64位的,请注意并下载WindowX86-64版本。另外,您还必须安装postgreSQL并在PATH变量中进行设置。例如C:\Program Files\PostgreSQL\12\bin是我在PC上看到的路径。