VSCode 没有选择 ipykernel [英] VSCode not picking up ipykernel

查看:179
本文介绍了VSCode 没有选择 ipykernel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 python 扩展将 vscode 与 jupyter 一起使用.我的 pipfile 看起来像这样:

I'm trying to use vscode with jupyter via the python extension. My pipfile looks like this:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
opencv-python = "*"

[requires]
python_version = "3.6"

[dev-packages]
ipykernel = "*"
ipython = "*"
jupyter = "*"

要启动 ipython 解释器,我按照以下步骤操作:

To start the ipython interpreter i follow these steps:

  • $ pipenv 安装
  • $ pipenv 外壳
  • $ 代码.
  • 使用 Python:选择解释器,我选择 pipenv 环境
  • 运行代码

当我按 shift + enter 进入代码块时,我看到了错误:

when i got to the code block by pressing shift + enter, i see the errors:

代码块:

#%%
import cv2

我也尝试过使用 [packages] 部分中的所有依赖项,从头开始重新安装我的 pipenv,并重复上述过程.

I have also tried using all dependencies in the [packages] section, reinstalling my pipenv from scratch, and repeating the above process.

总是同样的错误,我错过了什么?

Always the same error, what am i missing?

$ code -v
1.41.1
26076a4de974ead31f97692a0d32f90d735645c0
x64

推荐答案

原来我安装的python是python3.x,但没有安装python3.x-dev.

Turns out that the python I had installed python3.x, but not python3.x-dev.

您可以使用以下方法安装:

You can install this using:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update -y && sudo apt upgrade
sudo apt install python3.8 python3.8-dev

打开 vscode 后,我点击 ctrl + shift + P 并选择 Python: Select Interpreter 并选择包含 ipykernel 的虚拟环境.

Upon opening vscode i then hit ctrl + shift + P and selected Python: Select Interpreter and selected the virtual env containing ipykernel.

这篇关于VSCode 没有选择 ipykernel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆