我在RHEL 7、Python 3.6和Postgres中的环境位于RDS集群上。我用Pycharm来发展。我做的
python-mpipinstallpsycopg2
它给出了错误
command gcc failed with exit status 1
为了纠正错误,我尝试安装psycopg2二进制文件,但我需要psycopg2包通过python脚本连接到postgres。如果我使用SQLAlchemy,它将通过psycopg2包进行指导。
我尝试了sudo-yum安装postgresql-libs。。。。sudo-yum安装postgresql-devel,但问题仍然存在。
完全错误:
[priya@localhost psycopg2-2.9.1]$ pip install psycopg2
Defaulting to user installation because normal site-packages is not writeable
Collecting psycopg2
Using cached psycopg2-2.9.1.tar.gz (379 kB)
Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-2rdr62wb/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/priya/.local/include/python3.6m/psycopg2
cwd: /tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/
Complete output (38 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/psycopg
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=90224 -DPSYCOPG_DEBUG=1 -I/usr/include/python3.6m -I. -I/usr/include -I/usr/include/pgsql/server -I/usr/include/libxml2 -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:0:
./psycopg/psycopg.h:35:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-2rdr62wb/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/priya/.local/include/python3.6m/psycopg2 Check the logs for full command output.
解决方案:
sudo yum repo-pkgs rhel-7-server-optional-rpms list | grep python3
sudo yum install python3-devel.x86_64 --enablerepo=rhel-7-server-optional-rpms
pip install psycopg2
提供:Jonathan关于如何在red hat 7上安装python3-devel的回答
本文向大家介绍Vmware12虚拟机安装教程 Vmware12虚拟机上安装Oracle,包括了Vmware12虚拟机安装教程 Vmware12虚拟机上安装Oracle的使用技巧和注意事项,需要的朋友参考一下 Vmware12虚拟机及Oracle安装教程分享给大家,具体内容如下 1、安装XP系统 步骤一: 步骤二: 选择使用现有的虚拟盘,然后加载系统文件即可 系统XP安装成功,检测一下主机和虚拟机的
问题内容: 是否可以在RHEL7上的特定版本17.03中安装DockerCE? 这里有信息: 关于在RHEL上安装Docker的https://docs.docker.com/engine/installation/linux/rhel/#install-using-the-repository,但没有版本信息。 在这里使用Docker 17.03,但仅在Docker EE中而不是 Docker
前面小节介绍了 Linux 和 GUN 项目,本小节开始学习如何在 Windows 上安装虚拟机,虚拟机安装之后可以在虚拟机中安装 Linux 相关的操作系统,常见的虚拟机软件有 VirtualBox、VMware 等等,本教程使用 VMware 虚拟机软件来演示如何安装 VMware 虚拟机: 1. 下载 VMware 来到官网下载 Windows 版本 VMware 安装程序,如图所示选择合适
我在 Azure 虚拟机上安装 Docker 时遇到错误。 m/c 配置:Azure vm、Windows 10 企业版、英特尔 2.4 GHz、7 GB RAM、64 位操作系统、基于 x64 的处理器。我浏览了几个博客,他们要求我在 azure vm 上启用嵌套虚拟化,如下所示。 设置VMProcessor-VMName MobyLinuxVM-ExposeVirtualizationExte
本文向大家介绍linux虚拟机上安装配置redis3.0.7,包括了linux虚拟机上安装配置redis3.0.7的使用技巧和注意事项,需要的朋友参考一下 我们给大家列出详细的图文步骤教给大家在linux虚拟机上安装redis以及相关的配置流程。 将redis-3.0.7.tar.gz上传到linux虚拟机上编译: a) 因为redis是C语言开发,所以需要先编译,在linux上编译需要依赖gc