简体   繁体   English

我可以在没有所有开销的情况下在 Visual Studio Code 中运行 python 吗?

[英]Can I run python in Visual Studio Code without all the overhead?

I have both python and Visual Studio Code installed.我安装了 python 和 Visual Studio Code。 However, when I run python within it, it adds a lot of overhead to each run, looking for MS specific python libraries and whatnot.但是,当我在其中运行 python 时,它会为每次运行增加大量开销,查找 MS 特定的 python 库等等。 Is there a way to run python code without all of the MS overhead?有没有办法在没有所有 MS 开销的情况下运行 python 代码?

In effect, can I configure Visual Studio Code to just kick off a console/terminal call to my local python interpreter with the script name and just run like that?实际上,我可以将 Visual Studio Code 配置为使用脚本名称启动对本地 python 解释器的控制台/终端调用,然后就这样运行吗? I would be fine if VSC would just run something like C:\\python\\python.exe myscript.py and show it to me in the terminal window.如果VSC只运行像C:\\python\\python.exe myscript.py这样的东西并在终端窗口中显示给我,我会很好。

Instal node.js and nodemon:安装 node.js 和 nodemon:

npm i -g nodemon

then run然后运行

nodemon --exec pythonVersion filename

example例子

nodemon --exec python3.7 file.py 

On every file change, this re-run command.在每次文件更改时,此重新运行命令。

Good idea is to put this script into .sh file好主意是将此脚本放入 .sh 文件中

Use the Code Runner extension.使用代码运行器扩展。 It runs the Python script as you described.它按照您的描述运行 Python 脚本。

我认为如果您右键单击 - >“在终端中运行 Python 文件”,它应该可以满足您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM