Skip to content
Sign upLog in
← Back to Community
Trouble installing psycopg2
Profile icon
hacker
has Hacker Plan
pythonIsSnake

I wanna use MQTT but I cannot install a dependency:

  • psycopg2 (2.8.6)

[EnvCommandError]
Command ['/opt/virtualenvs/python3/bin/pip', 'install', '--no-deps', 'psycopg2==2.8.6'] errored with the following return code 1, and output:
Collecting psycopg2==2.8.6
Using cached https://files.pythonhosted.org/packages/fd/ae/98cb7a0cbb1d748ee547b058b14604bd0e9bf285a8e0cc5d148f8a8a952e/psycopg2-2.8.6.tar.gz
ERROR: Command errored out with exit status 1:
command: /opt/virtualenvs/python3/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-__sklf4u/psycopg2/setup.py'"'"'; file='"'"'/tmp/pip-install-__sklf4u/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 /tmp/pip-install-__sklf4u/psycopg2/pip-egg-info
cwd: /tmp/pip-install-__sklf4u/psycopg2/
Complete output (23 lines):
running egg_info
creating /tmp/pip-install-__sklf4u/psycopg2/pip-egg-info/psycopg2.egg-info
writing /tmp/pip-install-__sklf4u/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-install-__sklf4u/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to /tmp/pip-install-__sklf4u/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file '/tmp/pip-install-__sklf4u/psycopg2/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>). ----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.3.1; however, version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

exit status 1

Voters
Profile icon
pythonIsSnake
Comments
hotnewtop
Profile icon
maysaaenables2

What system do you use to install it? And what is the architecture of the original system? Did you manage to solve the problem by reinstalling it? I have seen something like this happen on a system using mqtt broker high availability, but it did not take a programmer long to fix it. It was something about variable numbers in the code. I could not understand the core reason for the error, but it never occurred again, so I didn’t have to deal with it anymore. So, I would not say it’s a common problem because it was the only case it occurred in my practice.

Profile icon
RYANTADIPARTHI

maybe it's not available in repl.it. Try installing again. IF it doesn't work, then it's not available in repl.it