skip to Main Content

I am facing this issue when trying to run psycopg2, any one with solution would be helpful, thanx!

Collecting psycopg2==2.8.6 (from -r requirements.txt (line 45))
  Using cached psycopg2-2.8.6.tar.gz (383 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [37 lines of output]
      running egg_info
      creating /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info
      writing /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/dependency_links.txt
      writing top-level names to /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/top_level.txt
      writing manifest file '/tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/SOURCES.txt'
      /home/lungsang/Desktop/Contextus/env/lib/python3.8/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
 
      
      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      
      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>).
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

This error appears when i try to run psycopg2 and I upgraded setuptools, still not solved.

3

Answers


  1. Chosen as BEST ANSWER

    Looks like I haven't installed PostgreSQL on my system. after installing, problem solved.


  2. Have you installed python-dev?
    If you already have, try also installing libpq-dev

    sudo apt install libpq-dev python-dev
    

    If didn’t fix, try psycopg2-binary:

    pip3 install psycopg2-binary
    
    Login or Signup to reply.
  3. Try installing pip install psycopg2-binary it is a more stable package.
    or if you are on mac try brew install postgresql

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search