VSCode 上的 Jupyter 扩展带来了错误的解释器

时间:2021-05-01 03:16:16

标签: python visual-studio-code virtualenv jupyter virtual-environment

enter image description here Kernel is selected as "AI", but brings normal Python37 interpreter

在前两行中,我打印了当前的可执行路径,但它没有加载正确的路径 C:\pyvenv\ai\Scripts\python.exe

3 个答案:

答案 0 :(得分:0)

你在你的python环境中安装了张量流的pip吗?

答案 1 :(得分:0)

我之前也遇到过同样的问题,您需要做的是创建一个虚拟环境并将该 venv 添加到 Jupyter Notebook。完成此操作后,您将能够在该 venv 中运行您的笔记本。

这里有一篇很好的文章可以帮助您解决这个问题:https://janakiev.com/blog/jupyter-virtual-envs/

答案 2 :(得分:0)

我发现此方法比 ipykernel install 方法更易于管理和理解,因为您可以在完成后删除虚拟环境。


  1. 在您想要的环境中安装 Jupyter,在您的情况下:
C:\pyvenv\ai\Scripts\python.exe -m pip install jupyterlab
  1. 在 VSCode 中,使用 CTRL+SHIFT+P (+ SHIFT+P(在 Mac 上)并选择 "Jupyter: Select interpreter to start Jupyter server" 命令

  2. 从内核列表中选择您刚刚用于安装 jupyter 的 Python 解释器(我必须重新启动 VSCode 才能让环境显示在该列表中)。