bug: failed installation using poetry
tried installing 'vanna[postgres]' using poetry on freshly installed ubuntu 22, it failed.
Package operations: 1 install, 0 updates, 0 removals
• Installing psycopg2 (2.9.9): Failed
ChefBuildError
Backend subprocess exited when trying to invoke get_requires_for_build_wheel
running egg_info
writing psycopg2.egg-info/PKG-INFO
writing dependency_links to psycopg2.egg-info/dependency_links.txt
writing top-level names to psycopg2.egg-info/top_level.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>).
at ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/installation/chef.py:164 in _prepare
160│
161│ error = ChefBuildError("\n\n".join(message_parts))
162│
163│ if error is not None:
→ 164│ raise error from None
165│
166│ return path
167│
168│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
Note: This error originates from the build backend, and is likely not a problem with poetry but with psycopg2 (2.9.9) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "psycopg2 (==2.9.9)"'.
We have noticed problems with psycopg2 on mac as well.
Instead of doing installing vanna[postgres], can you try installing just vanna and then for connecting to your Postgres database, install a different driver that works for you?
Regardless of the Vanna install, if you can create a function called run_sql that takes in a SQL statement and returns a dataframe, you should be able to drop that into the code like in the example below and the rest should work as expected.
import pandas as pd
# There's usually a library for connecting to your type of database. Any SQL database will work here -- you just have to use the right library.
conn_details = {...} # fill this with your connection details
conn = ... # fill this with your connection object
# You define a function that takes in a SQL query as a string and returns a pandas dataframe
def run_sql(sql: str) -> pd.DataFrame:
df = pd.read_sql_query(sql, conn)
return df
# This gives the package a function that it can use to run the SQL
vn.run_sql = run_sql
vn.run_sql_is_set = True
If you're able to get any run_sql function up and running, could you please let us know? Thank you!
@vikyw89 Potential workaround
Use psycopg2-binary instead of trying to build works for me (at least during installation)
The installation tries to build it, but you can install the psycopg2 binary instead
https://github.com/seanmavley/vanna/blob/main/pyproject.toml#L32
Great to know
On Sun, Jan 21, 2024, 9:53 PM KhoPhi @.***> wrote:
@vikyw89 https://github.com/vikyw89 Potential workaround
Use psycopg2-binary instead of trying to build works for me (at least during installation)
The installation tries to build it, but you can install the psycopg2 binary instead
https://github.com/seanmavley/vanna/blob/c804513ea5bfa7715df724fd123350e2920ec4c7/pyproject.toml#L32
— Reply to this email directly, view it on GitHub https://github.com/vanna-ai/vanna/issues/166#issuecomment-1902636522, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2W6KA4SIXVPHYT5FBRZLJ3YPUMXHAVCNFSM6AAAAABCDZ5QYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSGYZTMNJSGI . You are receiving this because you were mentioned.Message ID: @.***>
@vikyw89 Potential workaround
Use
psycopg2-binaryinstead of trying to build works for me (at least during installation)The installation tries to build it, but you can install the psycopg2 binary instead
https://github.com/seanmavley/vanna/blob/main/pyproject.toml#L32
this seems to be working, using psycopg2-binary instead of psycopg2
@vikyw89 thank you for the update. We can change the dependency to psycopg2-binary