如何在使用VS Code运行Jupyter Notebook时向Python传递选项。

huangapple go评论69阅读模式
英文:

How to pass option to python when I'm running a jupyter notebook on VS Code

问题

I've created a virtual environment using venv and I'm using such an environment in Visual Studio Code to run a Jupyter notebook.

Now, my code stops running, and from the log, I can read 2 warnings: one of which is

warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

Let's suppose I want to pass -Xfrozen_modules=off to Python to see what happens. How can I do it? I mean, I'm not running Python from the command line; I'm just pressing Shift+Enter in Visual Studio Code to execute the code cells of my notebook. How can I pass options to Python in Visual Studio Code?

英文:

I've created a virtual environment using venv and I'm using such environment in Visual Studio Code to run a jupyter notebook.

Now, my code stops running and from the log I can read 2 warnings: one of which is

warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

Let's suppose I want to pass -Xfrozen_modules=off to python to see what happens, how can I do it? I mean: I'm not running python from command line, I'm just pressing Shift+Enter in Visual Studio Code to execute the code cells of my notebook; how can I pass option to python in Visual Studio Code?

答案1

得分: 0

你可以将 "jupyter.jupyterCommandLineArguments": ["-Xfrozen_modules=off"], 添加到你的工作区的 .vscode/settings.json 中吗?

英文:

Can you not just put "jupyter.jupyterCommandLineArguments": ["-Xfrozen_modules=off"], in your workspace's .vscode/settings.json?

答案2

得分: 0

找到虚拟环境文件夹下 Jupyter 内核的 kernel.json 文件。应该位于以下路径

...\venv\share\jupyter\kernels\python3\kernel.json

打开 kernel.json 文件,在 "argv" 中添加 -Xfrozen_modules=off 参数。

英文:

Find the kernel.json file of the jupyter kernel under the virtual environment folder. It should be in the following path

...\venv\share\jupyter\kernels\python3\kernel.json

Open the kernel.json file and add the -Xfrozen_modules=off parameter in "argv".

如何在使用VS Code运行Jupyter Notebook时向Python传递选项。

huangapple
  • 本文由 发表于 2023年5月22日 18:02:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76305034.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定