gpt4 book ai didi

python-3.x - Nix openai python 开发环境构建失败

转载 作者:行者123 更新时间:2023-12-04 03:49:09 24 4
gpt4 key购买 nike

我正在尝试使用 nix 创建一个包含 openai pypi 包的 python37 开发环境。

question was originally on reddit ,但我找不到答案,并且线程中的事件非常低。

使用我得到的技巧和语言框架文档,我设法得出以下表达式:

默认.nix:

with import<nixpkgs>{};
( let
openai = pkgs.callPackage ./release.nix {
inherit pkgs;
buildPythonPackage = pkgs.python37Packages.buildPythonPackage;
};
in pkgs.python37.buildEnv.override rec {
extraLibs = [ pkgs.python37Packages.requests openai ];
}
).env

发布.nix

{ pkgs, buildPythonPackage }:

buildPythonPackage rec{
pname="openai";
version="0.2.6";

src=fetchTarball{
url="https://files.pythonhosted.org/packages/59/2d/b3bc2aa663b2c376f073fd141e128ecfb47f3aff95ccee284a74d85a1ef8/openai-0.2.6.tar.gz";
sha256="0cplrzfw3i6yxcd35ijfjkx9jbcvkvzn5jn5b8s657a8myhm6kav";
};

propagateBuildInputs = [ pkgs.python37Packages.requests ];
doCheck=false;

meta = { # only for testing the env right now
homepage="...";
description="...";
license = "...";
maintainers= [];
};
}

然而,这给我留下了(我猜是它的 pip-)错误

Processing ./openai-0.2.6-py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement requests>=2.20; python_version >= "3.0" (from openai==0.2.6) (from versions: none)
ERROR: No matching distribution found for requests>=2.20; python_version >= "3.0" (from openai==0.2.6)
builder for '/nix/store/ncnga4fcxl15xyvv3f325f9g0q45mqvr-python3.7-openai-0.2.6.drv' failed with exit code 1

这让我感到惊讶,因为 propagateBuildInputs = [ pkgs.python37Packages.requests ]; 清楚地指出包 requests(nixpkgs 中的版本 2.22.0)应该出现在构建时间。

我对阻止它工作的 buildPythonPackage 函数有什么误解?

最佳答案

progagatedBuildInputs 更改为另一个名称,如 progagateBuildInputs 会导致它被忽略,因此找不到它包含的任何依赖项(即 requests)。例如:

yubico-client/default.nix

propagateBuildInputs = [ requests ];

ERROR: Could not find a version that satisfies the requirement requests<3.0,>=2.7 (from yubico-client==1.13.0) (from versions: none)
ERROR: No matching distribution found for requests<3.0,>=2.7 (from yubico-client==1.13.0)

propagatedBuildInputs = [ requests ];

$ nix-build -I nixpkgs=~/git/nixpkgs '<nixpkgs>' -k -A python37Packages.yubico-client
/nix/store/0yjz8smgmjr0006nmka6wliy01z8av7m-python3.7-yubico-client-1.13.0

关于python-3.x - Nix openai python 开发环境构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64677802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com