Kedro使用错误的Conda环境
我创建了一个名为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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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 bysys.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 toipykernel.kernelspec.install
. This generates a kernelspec that points towards the Python path given bysys.executable
(seemake_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.这可能是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.
尝试在您的foo设想中安装jupyterlab,jupyter内核是一个不同的概念,有时会起作用。
Try do pip install jupyterlab in your foo enviornment, Jupyter Kernel is a different concept and acts weird sometimes.