# How to enable plpython3u in PostgreSQL

**URL:** https://discourse.nixos.org/t/how-to-enable-plpython3u-in-postgresql/64674
**Category:** Help
**Created:** [May 23, 2025, 10:42pm UTC](https://discourse.nixos.org/t/how-to-enable-plpython3u-in-postgresql/64674 "2025-05-23T22:42:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![munnik](https://discourse.nixos.org/user_avatar/discourse.nixos.org/munnik/32/27132_2.png) [@munnik](https://discourse.nixos.org/u/munnik)
#### Post date: [May 23, 2025, 10:42pm UTC](https://discourse.nixos.org/t/how-to-enable-plpython3u-in-postgresql/64674/1 "2025-05-23T22:42:31Z")

</div>

Hi,

I have a database running in docker that I want to migrate to native Nixos. I can’t get the `plpython3u` available in PostgreSQL. From what I understand, Python should be enabled if it is available on the system ([nixpkgs/pkgs/servers/sql/postgresql/generic.nix at 55d1f923c480dadce40f5231feb472e81b0bab48 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/blob/55d1f923c480dadce40f5231feb472e81b0bab48/pkgs/servers/sql/postgresql/generic.nix#L106)). I also saw this [post](https://discourse.nixos.org/t/using-pythonpackages-in-postgresql/59333) and tried the override without success. I’ve enabled Python on the system with

```nix
environment.systemPackages = [pkgs.python3];

```

```bash
sudo -u postgres /nix/store/n4gj0dmk2wpwl08s6sqng2f0jdqqkrjs-postgresql-and-plugins-17.5/bin/psql -h /tmp/tmp.sYB9hVQAgz -X -d gosk -c 'ALTER EXTENSION plpython3u UPDATE;'
WARNING: database "gosk" has a collation version mismatch
DETAIL: The database was created using collation version 2.35, but the operating system provides version 2.40.
HINT: Rebuild all objects in this database that use the default collation and run ALTER DATABASE gosk REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.
ERROR: extension "plpython3u" is not available
DETAIL: Could not open extension control file "/nix/store/gbniv0b4hm6pjky7f1iyradwdmb4g4l0-postgresql-and-plugins-15.13/share/postgresql/extension/plpython3u.control": No such file or directory.
HINT: The extension must first be installed on the system where PostgreSQL is running.

```

---

<div class="post-metadata">

### Author: ![robsliwi](https://discourse.nixos.org/user_avatar/discourse.nixos.org/robsliwi/32/31820_2.png) [@robsliwi](https://discourse.nixos.org/u/robsliwi)
#### Post date: [May 24, 2025, 5:49am UTC](https://discourse.nixos.org/t/how-to-enable-plpython3u-in-postgresql/64674/2 "2025-05-24T05:49:05Z")

</div>

Have you tried to use a PostgreSQL with pythonSupport explicitly enabled?

For example:

```nix
    services.postgresql = {
      package = pkgs.postgresql_16.override {
        pythonSupport = true;
        inherit (pkgs) python3;
      };
    };

```

---

<div class="post-metadata">

### Author: ![wolfgangwalther](https://discourse.nixos.org/user_avatar/discourse.nixos.org/wolfgangwalther/32/29720_2.png) [@wolfgangwalther](https://discourse.nixos.org/u/wolfgangwalther)
#### Post date: [May 24, 2025, 6:32am UTC](https://discourse.nixos.org/t/how-to-enable-plpython3u-in-postgresql/64674/3 "2025-05-24T06:32:02Z")

</div>

With NixOS 25.05, or more specifically with [postgresql: provide PL/Perl, PL/Python and PL/Tcl as packages by wolfgangwalther · Pull Request #385859 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/pull/385859), we moved the core procedural languages (PL/Perl, PL/Python, PL/Tcl) to **packages**. This has the advantage, that PostgreSQL needs to be only built once, with python support enabled - even you want to add more python dependencies. To actually use the extension, you’ll then have to enable it explicitly, though.

For NixOS, this is described in the documentation: [NixOS Manual](https://nixos.org/manual/nixos/stable/#module-services-postgres-pls)

TLDR: `services.postgresql.extensions = ps: [ps.plpython3];`

For just Nixpkgs, without NixOS, you’ll have to use `postgresql.withPackages (ps: [ps.plpython3])` as your PostgreSQL package.

---

<div class="post-metadata">

### Author: ![munnik](https://discourse.nixos.org/user_avatar/discourse.nixos.org/munnik/32/27132_2.png) [@munnik](https://discourse.nixos.org/u/munnik)
#### Post date: [May 24, 2025, 8:02am UTC](https://discourse.nixos.org/t/how-to-enable-plpython3u-in-postgresql/64674/4 "2025-05-24T08:02:06Z")

</div>

> [@wolfgangwalther](#):
>
> For NixOS, this is described in the documentation: [NixOS Manual](https://nixos.org/manual/nixos/stable/#module-services-postgres-pls)

Somehow I missed this documentation entirely. I was checking out [this wiki](https://wiki.nixos.org/wiki/PostgreSQL) and [this wiki](https://nixos.wiki/wiki/PostgreSQL) and didn’t realize that the answer would be in the manual 🤭  
Thank you very much for you help!

---

<div class="post-metadata">

### Author: ![munnik](https://discourse.nixos.org/user_avatar/discourse.nixos.org/munnik/32/27132_2.png) [@munnik](https://discourse.nixos.org/u/munnik)
#### Post date: [May 24, 2025, 8:15am UTC](https://discourse.nixos.org/t/how-to-enable-plpython3u-in-postgresql/64674/5 "2025-05-24T08:15:06Z")

</div>

I tried, but I didn’t set the python3 attribute. I thought that it would default to python3 when not set.
