1
resposta

Problema com instalação do django-heroku

Durante a instalação apareceu esse erro e me travou no curso :(

 ERROR: Command errored out with exit status 1:
     command: /home/lorraine/Documentos/Mentoria/RestAPI_Clientes/RestAPI_Clientes/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v5x6k5x0/psycopg2_eaeeead0fd8f4d869afc3a2f490f778c/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v5x6k5x0/psycopg2_eaeeead0fd8f4d869afc3a2f490f778c/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-_knnf0zg/install-record.txt --single-version-externally-managed --compile --install-headers /home/lorraine/Documentos/Mentoria/RestAPI_Clientes/RestAPI_Clientes/venv/include/site/python3.8/psycopg2
         cwd: /tmp/pip-install-v5x6k5x0/psycopg2_eaeeead0fd8f4d869afc3a2f490f778c/
    Complete output (38 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/psycopg2
    copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
    running build_ext
    building 'psycopg2._psycopg' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/psycopg
    gcc -pthread -B /home/lorraine/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120008 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/lorraine/Documentos/Mentoria/RestAPI_Clientes/RestAPI_Clientes/venv/include -I/home/lorraine/anaconda3/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
    In file included from psycopg/psycopgmodule.c:28:
    ./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: Arquivo ou diretório inexistente
       36 | #include <libpq-fe.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: /home/lorraine/Documentos/Mentoria/RestAPI_Clientes/RestAPI_Clientes/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v5x6k5x0/psycopg2_eaeeead0fd8f4d869afc3a2f490f778c/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v5x6k5x0/psycopg2_eaeeead0fd8f4d869afc3a2f490f778c/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-_knnf0zg/install-record.txt --single-version-externally-managed --compile --install-headers /home/lorraine/Documentos/Mentoria/RestAPI_Clientes/RestAPI_Clientes/venv/include/site/python3.8/psycopg2 Check the logs for full command output.
1 resposta

Olá,

seu sistema não esta conseguindo compilar a lib. Pelo menos é isso que o erro está logando.

A psycopg2-binary resolve isso. Altere no seu requirements para psycopg2-binary.

Apesar de existir outras possiveis soluções, eu nunca utilizo a django-heroku. Ela não é essencial para deploy no Heroku.

Caso opte por não utilizá-la, o que recomendo, é só não add as configs no settings.py.

[]'s