Kedro使用错误的Conda环境

发布于 2025-01-29 15:45:50 字数 587 浏览 4 评论 0原文

我创建了一个名为foo的conda环境。激活此环境后,我使用pip安装了Kedro,因为conda给我冲突。即使我在foo环境中,当我运行时:

kedro jupyter lab

它可以从我的base环境中拾取模块,而不是foo环境。任何想法,为什么会发生这种情况,以及我如何更改笔记本检测到的模块?

edit

通过使用我的代码进行操纵,我发现在\ appdata \ roaming \ jupyter \ kernels \ kernels \ kedro_project \ kernel.json.json上不是foo环境。我手动更改它,但是是否有一种模式自动方法来设置\ appdata \ roaming \ jupyter \ kernels \ kernels \ kedro_project \ kernel.json使用我所处的当前环境?

I have created a conda environment called Foo. After activating this environment I installed Kedro with pip, since conda was giving me a conflict. Even though I'm inside the Foo environment, when I run:

kedro jupyter lab

It picks up the modules from my base environment, not the Foo environment. Any idea, why this is happening, and how I can change what modules my notebook detect?

Edit

By mangling with my code I found out that on the \AppData\Roaming\jupyter\kernels\kedro_project\kernel.json it was calling the python from the base environment, not the Foo environment. I changed it manually, but is there a mode automatic way of setting the \AppData\Roaming\jupyter\kernels\kedro_project\kernel.json to use the current environment I'm on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寄与心 2025-02-05 15:45:50

Custom Kedro内核规范是我最近添加到Kedro的功能。当您运行Kedro Jupyter Lab/Notebook时,它应该在Conda环境上自动拾取,而无需手动编辑kernel.json文件。我自己对此进行了测试以检查它是否有效,因此我对了解这里发生的事情非常感兴趣!

功能 是使Kedro内核规范的原因。这是解释发生了什么的docString,但简而言之,我们将 ipykernel.kernelspec.install 。 This generates a kernelspec that points towards the Python path given by sys.executable (see

值得检查哪个Kedro可以查看指向哪个CONDA环境,如果我们需要进一步调试,请在我们的 github repo 。我绝对想了解这一点,并了解问题所在。

PS您还可以执行一个普通的Jupyter Lab/Notebook以启动具有正确的Conda环境的内核,然后在第一个单元格中运行load_ext kedro.extras.extras.extensions.ipython 。这基本上等同于使用Kedro kernelspec,该kedro kernelspec自动加载kedro ipython扩展。

The custom Kedro kernel spec is a feature that I recently added to Kedro. When you run kedro jupyter lab/notebook it should automatically pick up on the conda environment without you needing to manually edit the kernel.json file. I tested this myself to check that it worked so I'm very interested in understanding what's going on here!

The function _create_kernel is what makes the the Kedro kernel spec. The docstring for that explains what's going on, but in short we delegate to ipykernel.kernelspec.install. This generates a kernelspec that points towards the Python path given by sys.executable (see make_ipkernel_cmd). In theory this should already point towards the correct Python path, which takes account of the conda environment.

It's worth checking which kedro to see which conda environment that points to, and if we need to debug further then please do raise an issue on our Github repo. I'd definitely like to get to the bottom of this and understand where the problem is.

P.S. you can also do a plain jupyter lab/notebook to launch a kernel with the right conda environment and then run %load_ext kedro.extras.extensions.ipython in the first cell. This is basically equivalent to using the Kedro kernelspec, which loads the Kedro IPython extension automatically.

糖粟与秋泊 2025-02-05 15:45:50

这可能是Jupyter的问题。我建议尝试运行Jupyter笔记本,并了解它是否归功于Kedro或Jupyter。

我记得由于某些jupyter问题而面临类似的事情,但不记得我是如何修复的。我记得尝试过一些解决方案
在jupyter上这个问题

This is likely a problem with jupyter. I'd suggest trying to run jupyter notebook and understand if it is down to kedro or jupyter.

I remember facing something similar due to some jupyter problem but don't remember how I fixed it. I remember trying some solutions from
this issue on jupyter.

情话难免假 2025-02-05 15:45:50

尝试在您的foo设想中安装jupyterlab,jupyter内核是一个不同的概念,有时会起作用。

Try do pip install jupyterlab in your foo enviornment, Jupyter Kernel is a different concept and acts weird sometimes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文