在VSCode中运行无需互联网连接的.py脚本。

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

Running .py script in VSCode with no internet connection

问题

未找到答案,我认为这是一个简单/常见的问题:

我正在使用VSCode中的原始Python脚本(.py,而不是.ipynb)进行工作。我想要能够在没有互联网连接的情况下工作和运行此脚本(特别是在长途飞行中)。

我该如何做到这一点?

如果您能够指向一个让我使用交互式内核的解决方案,那就更好了(我一直在使用这些来进行“运行”我的当前工作流程,所以这是我的首选,但我会接受任何帮助)。

谢谢!!

(这是当我尝试在没有互联网连接的情况下运行交互式会话时看到的内容。它最终会超时,并且我会收到错误消息:由于等待端口被使用而无法启动内核“base (Python 3.10.9)”。
查看Jupyter日志以获取更多详细信息。)

在VSCode中运行无需互联网连接的.py脚本。

英文:

Searched high and low and have not found an answer to what I thought was a simple/common question:

I am working on a raw Python script in VSCode (.py, not .ipynb). I would like to be able to work on & run this script without an internet connection (specifically on a long plane ride).

How can I do this?

Bonus points if you are able to point me to a solution that lets me use an Interactive kernel (I've been using these for "runs" in my current workflow, so it would be my preference, however I'll take what I can get).

Thanks!!

(This is what I see when I try to run an interactive session with no internet connection. It eventually times out, and I receive the error: Unable to start Kernel 'base (Python 3.10.9)' due to a timeout waiting for the ports to get used.
View Jupyter log for further details.
)

在VSCode中运行无需互联网连接的.py脚本。

答案1

得分: 1

执行Python脚本(.py)不需要互联网,除非你的代码有特殊需要。

你只需要下载Python解释器,并在VSCode中选择正确的解释器(Ctrl+Shift+P --> Python: Select Interpreter)。

此外,执行Python脚本不需要Jupyter内核,它仅在执行Jupyter文件(.ipynb)时有效。

英文:

Executing python scripts (.py) does not require internet unless there is a specific need in your code.

You just need to download the python interpreter and select the correct interpreter in vscode (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> --> Python: Select Interpreter).

Also executing a python script doesn't require a jupyter kernel, it only works when you execute a jupyter file (.ipynb).

huangapple
  • 本文由 发表于 2023年6月25日 23:22:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76551122.html
匿名

发表评论

匿名网友

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

确定