Flakes for development enviroment

I am trying to set up jetbrains pycharm via flakes. I found the-nix-way flake templates and followed the instructions to set it up with direnv.

But when I try to install numpy in jetbrains i get this error

Original error was: libstdc++.so.6: cannot open shared object file: No such file or directory

I think this means my .venv dose not have a copy of or a path to libstdc++.

  1. how can i include this library into .venv?

right now I need to have python3 installed into my home.nix file to get jetbrains to see the interpreter.

  1. can the interpreter be inside a flake? If it is how can I add it to the flake?
  2. once its in the flake will jetbrains recognize it or will i need to add a custom run configuration?

any help will be appreciated please and thanks

Hello,

I think the search button will help since this is a common issue.

The wiki might help too: Python - NixOS Wiki

1 Like

In my experience you will have a much better time to install all the packages through Nix or use something like uv2nix.
When I tried the imperative way with Python I constantly run into these kind of problems.

1 Like

This is my very basic flake which I use to do Python development, it should solve the error:

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/master";
  };

  outputs = { self, nixpkgs }: let
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
  in {
    devShells.x86_64-linux.default = pkgs.mkShell {
      packages = with pkgs; [ pdm (python3.withPackages(p: with p; [ tkinter ])) linuxPackages_latest.perf virtualenv gcc14 gfortran14 zlib ];

      LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib/:${pkgs.zlib}/lib/";
    };
  };
}

Everything else I need I install with pdm inside the venv and it works fine.

Note that using LD_LIBRARY_PATH leads to a lot of runtime issues eventually, we’ve learned that the hard way with devenv python integration.

Definitely a hack but it’s the only reliable way that I could get my Python envs to work properly. I can imagine it causing issues for larger environments so it’s not a silver bullet.