我想在 NixOS 上的 Python3 中使用 Gtk3。这个命令
nix-shell -p gobject-introspection gtk3 'python3.withPackages(ps : with ps; [ pygobject3 ])'
允许
import gi
在 nix-shell 内的 python3 环境中。这就是我尝试在 configuration.nix 文件中为 Python3 定义 Gtk 的方式。
environment.systemPackages = with pkgs; [
gtk3
python3
python3Packages.pygobject3
python3Packages.pip
];
sudo nixos-rebuild switch
命令不会显示任何错误,但在python3环境中import gi
会导致:
ModuleNotFoundError: No module named 'gi'
我需要改变什么?
这是 NixOs 的全新安装,带有 Cinnamon DE、Python 3.11.8、Gtk 3.24。
这就是我修改我的 configuration.nix 文件的方法,感谢 @CharlesDuffy 的评论。
users.users.reb = {
isNormalUser = true;
description = "RB";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [
firefox
libreoffice-fresh
vlc
gtk3
(python3.withPackages (subpkgs: with subpkgs; [
pip
pygobject3
]))
# thunderbird
];
};