Confused about working with python venvs

I’m trying to figure out how to manage python venvs in the ‘normal’ way in nixos. I do a lot of small python projects, often using other people’s code/requirements.txt so this is essential.

To start with I followed the instructions on the wiki and created a pip-shell.nix containing

{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
  name = "pipzone";
  targetPkgs = pkgs: (with pkgs; [
    python39
    python39Packages.pip
    python39Packages.virtualenv
  ]);
  runScript = "bash";
}).env

I enter the shell and create the venv as on the wiki, then install the requirements (just numpy and matplotlib in this) with

pip install -r requriements.txt

when I try to run the simple test script such as

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 100)
y = np.exp(x)

plt.plot(x, y)

plt.show()

I get libz.so.1 not found

Any idea how I can manage this type of thing in the traditional way? Preferably using my normal zsh shell or at least a shell with the same plugins/aliases etc.

Thanks

edit: I’m on 23.05 using the python3 package installed in configuration.nix

Maybe you could use nix for all your dependencies:

{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
  name = "datazone";
  targetPkgs = pkgs: (with pkgs; [
    python39.withPackages (p: [
      p.numpy
      p.matplotlib
    ])
  ]);
}).env

If runScript didn’t work, i think you can try
nix-shell --command $SHELL

If I do this without creating a venv then numpy, matplotlib are not found. Am I missing something fundamental about nix shells? I make a file containing the above called pip-shell.nix and activate it with nix-shell pip-shell.nix.