1
resposta

Erro ao instalar psycopg2

Olá, estou com um problema ao instalar o psycopg2. Ele retorna erro quando vai instalar dentro da venv.

Detalhes do erro:

Collecting psycopg2
  Using cached https://files.pythonhosted.org/packages/a8/8f/1c5690eebf148d1d1554fc00ccf9101e134636553dbb75bdfef4f85d7647/psycopg2-2.8.5.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info\psycopg2.egg-info
    writing pip-egg-info\psycopg2.egg-info\PKG-INFO
    writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt
    writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt
    writing manifest file 'pip-egg-info\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>).


    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Marcos Lima Marinho\AppData\Local\Temp\pip-install-xpwhf2r1\psycopg2\

Fiz um teste e consegui instalar com a venv desativada, o problema esta na minha venv, pesquisei na internet, mas nada que achei deu resultado. Poderiam me ajudar?

1 resposta

Oi Marcos, tudo bem com você?

Dentro do ambiente virtual, explicite a versão 3 do pip:

pip3 install psycopg2 

Se você utiliza o Linux, adicione as dependências abaixo e após isso, tente executar o comando de instalação do psycopg2 novamente:

sudo apt-get install libpq-dev python-dev

Qualquer dúvida estou à disposição. Abraços e bons estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software