或在 nix-shell 中找不到工具

问题描述 投票:0回答:1

按如下方式启动 nix-shell

nix-shell -p python39Packages.ipython python39Packages.ortools --run ipython

随后

 import ortools

结果

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-0c521df57bb5> in <module>
----> 1 import ortools

ModuleNotFoundError: No module named 'ortools'

任何有关如何解决此问题的建议!

or-tools nix nixos nix-shell
1个回答
0
投票

如果 nix 没有符号链接 Python 包(

site-packages
),通常会出现这种情况。在这里,您需要使用以下命令组合所需的 Python 包:

nix-shell -p "python39.withPackages(ps: with ps; [ipython ortools])" --run ipython

然后,您将可以轻松导入或工具。生成这样的 shell 有一个额外的好处,它通常使命令更容易阅读。

© www.soinside.com 2019 - 2024. All rights reserved.