Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在windows中安装psycopg2时出错_Python_Django_Postgresql - Fatal编程技术网

Python 在windows中安装psycopg2时出错

Python 在windows中安装psycopg2时出错,python,django,postgresql,Python,Django,Postgresql,您好,我正在从事Django项目,在windows上安装psycopg2时出错 pip install psycopg2 我也试过了 pip install psycopg2-binary 但还是有错误 ERROR: Command errored out with exit status 1: command: 'c:\users\theuser\appdata\local\programs\python\python39\python.exe' -c 'import sys, setu

您好,我正在从事Django项目,在windows上安装psycopg2时出错

pip install psycopg2
我也试过了

pip install psycopg2-binary
但还是有错误

ERROR: Command errored out with exit status 1:
 command: 'c:\users\theuser\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\theuser\\AppData\\Local\\Temp\\pip-install-zh83zqbg\\psycopg2\\setup.py'"'"'; __file__='"'"'C:\\Users\\theuser\\AppData\\Local\\Temp\\pip-install-zh83zqbg\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j'
     cwd: C:\Users\theuser\AppData\Local\Temp\pip-install-zh83zqbg\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info
writing C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info\SOURCES.txt'

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'.

If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.

For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).

----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
错误:命令出错,退出状态为1:
命令:“c:\users\theuser\appdata\local\programs\python\python39\python.exe'-c”import sys,setuptools,tokenize;sys.argv[0]=“C:\\Users\\theuser\\AppData\\Local\\Temp\\pip-install-zh83zqbg\\psycopg2\\setup.py”“”__文件“''C:\\Users\\theuser\\AppData\\Local\\Temp\\pip-install-zh83zqbg\\psycopg2\\setup.py''”;f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(编译(代码,“'exec'”)“鸡蛋信息——鸡蛋库”C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r\u
cwd:C:\Users\theuser\AppData\Local\Temp\pip-install-zh83zqbg\psycopg2\
完整输出(23行):
运行蛋_信息
正在创建C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r\u j\psycopg2.egg-info
写入C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r\u j\psycopg2.egg-info\PKG-info
正在将依赖项链接写入C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r\u j\psycopg2.egg-info\dependency\u links.txt
将顶级名称写入C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r\u j\psycopg2.egg-info\top\u-level.txt
正在写入清单文件“C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r\u j\psycopg2.egg info\SOURCES.txt”
错误:找不到pg_配置可执行文件。
从源代码构建psycopg2需要pg_配置。请添加目录
将pg_config包含到$PATH,或使用
选项:
python setup.py build_ext--pg config/path/to/pg_config build。。。
或者使用'setup.cfg'中的pg_config选项。
如果您希望避免从源代码构建psycopg2,请安装PyPI
改为“psycopg2二进制”包。
有关更多信息,请查看“doc/src/install.rst”文件(另请访问
).
----------------------------------------
错误:命令出错,退出状态为1:python setup.py egg_info检查日志以获得完整的命令输出。

您没有在windows上安装postgres

关键是:

pip install psycopg2
错误:找不到pg_config可执行文件。
您没有安装开发工具(
pg_config
属于它们),或者安装可执行文件的目录不在您的
PATH
环境变量中