Reproducing a devenv environment containing a postgresql dependency

Hello,

I currently use a devenv environment which I am trying to migrate to Flox. My project is a Python project with a pyproject.toml file:

dependencies = [
    "geopy>=2.4.1",
    "ics>=0.7.2",
    "numpy>=2.1.3",
    "pandas>=2.2.3",
    "psycopg>=3.2.3",
    "python-dateutil>=2.9.0.post0",
    "requests>=2.32.3",
    "selenium>=4.26.1",
    "tabulate>=0.9.0",
    "langdetect",
]

and I also need to install the following system dependencies:

  packages = (with pkgs; [
    postgresql
    firefox-unwrapped
    geckodriver
    gcc-unwrapped # fix: libstdc++.so.6: cannot open shared object file
    libz # fix: for numpy/pandas import
  ]);

I tried to use the following command to install postgresql into my Flox environment activated with flox activate (Python packages are installed): flox install postgresql. However when I run my application I get the following error:

  File "scrape.py", line 7, in <module>
    import psycopg
  File ".flox/cache/python/lib/python3.12/site-packages/psycopg/__init__.py", line 9, in <module>
    from . import pq  # noqa: F401 import early to stabilize side effects
    ^^^^^^^^^^^^^^^^
  File ".flox/cache/python/lib/python3.12/site-packages/psycopg/pq/__init__.py", line 116, in <module>
    import_from_libpq()
  File ".flox/cache/python/lib/python3.12/site-packages/psycopg/pq/__init__.py", line 108, in import_from_libpq
    raise ImportError(
ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found

My questions:

  1. How can I make postgresql work inside my environment?
  2. Once postgresql is fixed, I will maybe have follow-up questions regarding the other system dependencies.

Thank you for your guidance

Hey!

I wasn’t able to reproduce the error with an example environment based on the same packages: Flox example with Python and Postgres · GitHub

It uses the composition feature and flox/postgres remote environment, so that I didn’t need to configure a Postgres server myself, but you could add the postgresql or libpq package to the [install] section of the manifest if you already have a server running elsewhere.

Are you able to provide the complete manifest.toml, pyproject.toml, and scrape.py (or an abbreviated version if it’s private) so that we can reproduce and help solve your issue?

Feel free to also add your other question about system dependencies in the meantime.