如何在 VS Code 的 Jupyter 笔记本中将单元格语言设置为 cython?

发布于 2025-01-10 00:11:25 字数 254 浏览 2 评论 0原文

我想使用内置的 jupyter 笔记本和 Cython 扩展在 vscode 中编写 Cython。我实际上可以做到这一点,并且它会编译得很好,但是 vscode 认为它是 python 代码,并且会抱怨各种语法和 linting 错误。我知道我可以用纯 python 模式编写,但我也在尝试同时学习 Cython,所以这不是很有帮助。

我尝试安装 Cython 语言扩展,但当我尝试切换单元语言时,它们都没有出现在 vscode 中。

这可能吗?我怎么能这样做呢?

I'd like to write Cython in vscode using the built-in jupyter notebook and Cython extension. I can actually do it and it will compile just fine, but vscode thinks it's python code and will complain about all kinds of syntax and linting errors. I know I could write in pure python mode, but I'm also trying to learn Cython simultaneously, so that's not very helpful.

I tried installing Cython language extensions, but none of them appeared in vscode when I tried to switch language of cell.

Is this possible? How could I do this?

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

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

发布评论

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

评论(1

云柯 2025-01-17 00:11:25

目前似乎不支持此功能(在撰写本文时)。

请参阅已关闭
Cythonized 笔记本单元渲染不正确
#11349
,已关闭,指向根据细胞魔法自动更改细胞语言#4588,我的理解是,一旦实现这些更改,您就可以使用像 %%cython 这样的细胞魔法,并且细胞的语言将自动更改为 cython。确切的细节似乎还没有 100% 充实,而且这个问题似乎对维护者来说并不是高度优先的,尽管他们在该线程中提到他们确实希望最终实现这一点。 您可以通过以下方式表达您对问题票证的支持对这个问题做出竖起大拇指的反应。但请不要发表“我也是”评论。“我也是”评论通常会让回购维护者感到厌烦,因为它们会扰乱讨论并且不会贡献任何重要的东西

为了您的学习目的/参考,我通过谷歌搜索“github vscode jupyter issues cython”并查看链接的 GitHub 问题找到了此信息。

It looks like this is not currently supported (at the time of this writing).

See Closed
Cythonized notebook cells render incorrectly
#11349
, which is closed pointing toward Automatically change cell language based on cell magics #4588, where my understanding is that once those changes are implemented, you'd be able to use a cell magic like %%cython, and the cell's language would automatically change to cython. The exact details don't seem 100% fleshed out yet, and the issue doesn't seem to be high priority to the maintainers, though they mention in that thread that they do want to get to implementing this eventually. You can show your support for the issue ticket by giving a thumbs up reaction to the issue. But please don't make a "me too" comment. "me too" comments generally come off as annoying to repo maintainers because they clutter up discussion and don't contribute anything of significant value.

For your learning purposes / reference, I found this information by googling "github vscode jupyter issues cython" and looking through linked GitHub issues.

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