错误Tips : https://www.psycopg.org/docs/install.html

举报
Yuchuan 发表于 2020/08/27 23:24:06 2020/08/27
【摘要】 安装python 环境记录踩过的坑。

报错代码:

(iotproenv) [root@hy-iot xuanyuaniotpro]# pip install django_heroku
Collecting django_heroku

  Using cached django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)

Requirement already satisfied: django in /home/root-yuchuan/bin/iotproenv/lib/python3.6/site-packages (from django_heroku) (1.11.11)

Collecting whitenoise

  Downloading whitenoise-5.2.0-py2.py3-none-any.whl (19 kB)

Collecting psycopg2

  Using cached psycopg2-2.8.5.tar.gz (380 kB)

Requirement already satisfied: dj-database-url>=0.5.0 in /home/root-yuchuan/bin/iotproenv/lib/python3.6/site-packages (from django_heroku) (0.5.0)

Requirement already satisfied: pytz in /home/root-yuchuan/bin/iotproenv/lib/python3.6/site-packages (from django->django_heroku) (2020.1)

Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.

Installing collected packages: whitenoise, psycopg2, django-heroku

    Running setup.py install for psycopg2 ... error

    ERROR: Command errored out with exit status 1:

     command: /home/root-yuchuan/bin/iotproenv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-idrfjzd5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-idrfjzd5/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 /tmp/pip-record-cle8dilc/install-record.txt --single-version-externally-managed --compile --install-headers /home/root-yuchuan/bin/iotproenv/include/site/python3.6/psycopg2

         cwd: /tmp/pip-install-idrfjzd5/psycopg2/

    Complete output (36 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/pool.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/__init__.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2

    copying lib/compat.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 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/home/root-yuchuan/bin/iotproenv/include -I/usr/include/python3.6m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement

    unable to execute 'gcc': No such file or directory   

    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: /home/root-yuchuan/bin/iotproenv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-idrfjzd5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-idrfjzd5/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 /tmp/pip-record-cle8dilc/install-record.txt --single-version-externally-managed --compile --install-headers /home/root-yuchuan/bin/iotproenv/include/site/python3.6/psycopg2 Check the logs for full command output.

尝试了很多:

(iotproenv) [root@hy-iot xuanyuaniotpro]# yum -y update
Last metadata expiration check: 2:33:42 ago on Thu 27 Aug 2020 11:26:16 AM UTC.
Dependencies resolved.

(iotproenv) [root@hy-iot xuanyuaniotpro]# yum upgrade
Last metadata expiration check: 2:35:49 ago on Thu 27 Aug 2020 11:26:16 AM UTC.
Dependencies resolved.
Nothing to do.
Complete!
(iotproenv) [root@hy-iot xuanyuaniotpro]#
(iotproenv) [root@hy-iot xuanyuaniotpro]# pip install psycopg2-binary
(iotproenv) [root@hy-iot xuanyuaniotpro]# yum install gcc
Last metadata expiration check: 2:37:39 ago on Thu 27 Aug 2020 11:26:16 AM UTC.
Dependencies resolved.

(iotproenv) [root@hy-iot xuanyuaniotpro]# yum install gcc-c++ 
Last metadata expiration check: 2:38:12 ago on Thu 27 Aug 2020 11:26:16 AM UTC.
Dependencies resolved.

(iotproenv) [root@hy-iot xuanyuaniotpro]# pip install psycopg2-binary
Requirement already satisfied: psycopg2-binary in /home/root-yuchuan/bin/iotproenv/lib/python3.6/site-packages (2.8.5)
(iotproenv) [root@hy-iot xuanyuaniotpro]# pip install psycopg2
Collecting psycopg2
  Using cached psycopg2-2.8.5.tar.gz (380 kB)
Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
    Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.8.5
(iotproenv) [root@hy-iot xuanyuaniotpro]#

(iotproenv) [root@hy-iot xuanyuaniotpro]# pip install -r requirements.txt

sudo yum install postgresql-devel (centos6X)
pip install psycopg2==2.5.2


【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200