# Reproducing a devenv environment containing a postgresql dependency

**URL:** <https://discourse.flox.dev/t/reproducing-a-devenv-environment-containing-a-postgresql-dependency/1141>\
**Category:** Help\
**Created:** [June 17, 2025, 9:09am UTC](https://discourse.flox.dev/t/reproducing-a-devenv-environment-containing-a-postgresql-dependency/1141 "2025-06-17T09:09:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![superuser](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@superuser](https://discourse.flox.dev/u/superuser)\
**Post date:** [June 17, 2025, 9:09am UTC](https://discourse.flox.dev/t/reproducing-a-devenv-environment-containing-a-postgresql-dependency/1141/1 "2025-06-17T09:09:14Z")

</div>

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:

```auto
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:

```auto
  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:

```auto
  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

---

<div class="post-metadata">

**Author:** ![dcarley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/dcarley/32/729_2.png) [@dcarley](https://discourse.flox.dev/u/dcarley)\
**Post date:** [June 20, 2025, 2:08pm UTC](https://discourse.flox.dev/t/reproducing-a-devenv-environment-containing-a-postgresql-dependency/1141/2 "2025-06-20T14:08:53Z")

</div>

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](https://gist.github.com/dcarley/2ad2c692c03490369359818e14283447)

It uses the [composition feature](https://flox.dev/docs/concepts/composition/) and [`flox/postgres`](https://hub.flox.dev/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.

---

<div class="post-metadata">

**Author:** ![superuser](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@superuser](https://discourse.flox.dev/u/superuser)\
**Post date:** [July 12, 2025, 6:42pm UTC](https://discourse.flox.dev/t/reproducing-a-devenv-environment-containing-a-postgresql-dependency/1141/3 "2025-07-12T18:42:38Z")

</div>

Thank you very much for your answer. The problem was not really related to flox in the end. Replacing `psycopg` with `psycopg[binary,pool]` in my pyproject file fixed my issue.

Thank you for your work on flox, I really appreciate it.

---

<div class="post-metadata">

**Author:** ![dcarley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/dcarley/32/729_2.png) [@dcarley](https://discourse.flox.dev/u/dcarley)\
**Post date:** [July 14, 2025, 10:26am UTC](https://discourse.flox.dev/t/reproducing-a-devenv-environment-containing-a-postgresql-dependency/1141/4 "2025-07-14T10:26:04Z")

</div>

Excellent, thanks for letting us know!
