LineaLabs / lineapy

Move fast from data science prototype to pipeline. Capture, analyze, and transform messy notebooks into data pipelines with just two lines of code.
https://lineapy.org
Apache License 2.0
664 stars 58 forks source link

Installing psycopg2 from requirements file #839

Closed lazargugleta closed 1 year ago

lazargugleta commented 1 year ago

python version: Python 3.10.6

lineapy version: 0.2.1

Your code:

pip install -r requirements.txt

Issue: psycopg2 library does not install with the requirements file.

Collecting psycopg2==2.9.3
  Using cached psycopg2-2.9.3.tar.gz (380 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
          /lineapy/env/lib/python3.10/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file 
parameter is deprecated, use license_files instead.
        warnings.warn(msg, warning_class)
      running egg_info
      creating /tmp/pip-pip-egg-info-200j4mcn/psycopg2.egg-info
      writing /tmp/pip-pip-egg-info-200j4mcn/psycopg2.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-pip-egg-info-200j4mcn/psycopg2.egg-info/dependency_links.txt
      writing top-level names to /tmp/pip-pip-egg-info-200j4mcn/psycopg2.egg-info/top_level.txt
      writing manifest file '/tmp/pip-pip-egg-info-200j4mcn/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>).

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

I found the solution to the problem:

sudo apt install python3-dev libpq-dev

And again, installing requirements goes without problems.

yoonspark commented 1 year ago

Hi @lazargugleta, thanks for this detailed bug report! Our team will investigate the issue and get back to you soon!

andycui97 commented 1 year ago

Interesting, I've actually run into this problem in the past before, but I decided to use psycopg2-binary instead. In fact, you can see this in the Dockerfiles for self-hosting example

https://github.com/LineaLabs/lineapy/blob/6a21605aca99d273c0a87b21ba1e64791552dc55/examples/self-hosting-lineapy/lineapy-notebook/Dockerfile#L25

I wonder if its better to use psycopg2-binary since its a "stand-alone package, not requiring a compiler or external libraries" which should make installing easier. Drawback is they say "The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources."

I think since Lineapy is mostly used in development right now, this is fine and we should switch over?

@yoonspark @lazargugleta thoughts?

lazargugleta commented 1 year ago

That occurred to me as well while trying to fix the issue. It would make sense since, as you said, Linea is in the development stage.

andycui97 commented 1 year ago

@lazargugleta ^

lazargugleta commented 1 year ago

Nicely done! :partying_face: