{
description = "virtual environment with python and streamlit";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
python=pkgs.python311;
f = ps: with ps;[
ipython
matplotlib
pandas
];
pip_python_packages= python.withPackages(f);
myDevTools = [
pip_python_packages
pkgs.streamlit
];
outputName = builtins.attrNames self.outputs self.outputs;
in {
devShells.default = pkgs.mkShell {
buildInputs = myDevTools;
};
packages.default = pkgs.poetry2nix.mkPoetryApplication {
projectDir = self;
};
apps.default = {
program = "${python}/bin/python";
args = [ "main.py" ];
src = "./.";
type = "app";
};
});
}
字符串
命令nix run“works”。不像预期的那样,它只打开python解释器,但这是另一个问题。
但是命令nix run不起作用
错误:...当评估属性'pkgs.buildPythonPackage'时
at /nix/store/s1z7nb9n6r5n0r34fabp6yybwkbr8mjk-source/pkgs/development/interpreters/python/passthrufun.nix:87:5:
86| withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;};
87| pkgs = pythonPackages;
| ^
88| interpreter = "${self}/bin/${executable}";
… while calling the 'mapAttrs' builtin
at /nix/store/s1z7nb9n6r5n0r34fabp6yybwkbr8mjk-source/pkgs/development/interpreters/python/passthrufun.nix:31:8:
30| value;
31| in lib.mapAttrs func items;
| ^
32| in ensurePythonModules (callPackage
(stack trace truncated; use '--show-trace' to show the full trace)
error: getting status of '/nix/store/ggvg85rp5qzyr9bngsl6r0pcrkyxqa49-source/poetry.lock': No
型
这样文件或目录
此错误消息不涉及我的代码的任何部分。这很难知道是哪个部分导致了问题
1条答案
按热度按时间w51jfk4q1#
为什么'nix run'会打开python解释器
flake中的“apps”属性集仅支持“program”和“type”属性。它只能用于二进制文件或shell脚本。它忽略了你的参数,只运行没有参数的python。你可以通过创建一个单独的二进制/脚本来运行并使用它,或者使用nix develop和shellHook来解决这个问题。
nix build为什么不行
字符串
锁很可能没有通过'gitadd'添加到您的git仓库中。Flake只知道已经提交或暂存在您的git仓库中的文件