简体   繁体   English

Pycharm安装psycopg2失败

[英]Failure to install psycopg2 in Pycharm

I'm trying to install psycopg2 to use a postgresql db in the backend of my django project, but every time I run the pip install psycopg2 command I get an error saying:我正在尝试安装 psycopg2 以在我的 django 项目的后端使用 postgresql 数据库,但每次运行pip install psycopg2命令时,我都会收到一条错误消息:

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:

    python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

I have added the \bin\ folder containing the file to my path, I've ran the pip install psycopg2-binary command as well, and I've uninstalled and reinstalled posgresql on my computer, I've also ran the python setup.py build_ext command mentioned in the error message, and this error still pops up.我已将包含该文件的 \bin\ 文件夹添加到我的路径中,我也运行了pip install psycopg2-binary命令,并且在我的计算机上卸载并重新安装了 posgresql,我还运行了python setup.py build_ext命令在错误消息中提到,仍然弹出此错误。 I'm operating on a windows 10 os and using posgresql 13.1.我在 windows 10 操作系统上运行并使用 posgresql 13.1。 Any suggestions?有什么建议么?

EDIT: This is the error I'm getting in my terminal:编辑:这是我在终端中遇到的错误:

Error in PyCharm terminal PyCharm终端错误

You've probably done this already, but the steps should be:你可能已经这样做了,但步骤应该是:

  1. Install PostgreSQL.安装 PostgreSQL。
  2. Add the PostgreSQL bin/ folder to your path.将 PostgreSQL bin/文件夹添加到您的路径。
  3. Restart your command line to make sure your path is set correctly.重新启动命令行以确保路径设置正确。
  4. Run pip install psycopg2运行pip install psycopg2

I have a clean install of Windows 10 over here and it seems to work for me.我在这里全新安装了 Windows 10,它似乎对我有用。 Running pip install psycopg2-binary should definitely work (even without PostgreSQL) because that doesn't compile anything, so I'm interested if you also have errors there.运行pip install psycopg2-binary应该绝对有效(即使没有 PostgreSQL),因为它不会编译任何东西,所以如果你在那里也有错误,我很感兴趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM