简体   繁体   English

更改 Python:在 Visual Studio Code 的终端命令中运行 Python 文件

[英]Change Python:Run Python File in Terminal command in Visual Studio Code

I am using an anaconda environment in VS code when suddenly the Run Python File in Terminal command bound to the green play-button in the top right corner stopped working.我在 VS 代码中使用 anaconda 环境时,突然在终端命令中运行 Python 文件绑定到右上角的绿色播放按钮停止工作。 It used to input: python_path file_path/file.py into the terminal and it worked perfectly fine.它曾经在终端中输入: python_path file_path/file.py并且它工作得很好。

But after running my code in the anaconda prompt program it has now changed to: & conda run -n env_name python file_path/file.py and now I get a ModuleNotFoundError, that I don't have cv2 installed, which I do.但是在 anaconda 提示程序中运行我的代码后,它现在已更改为: & conda run -n env_name python file_path/file.py并且现在我得到一个 ModuleNotFoundError,我没有安装 cv2,我这样做了。

I can still run the code if I simply input: python file_path/file.py .如果我只是输入: python file_path/file.py我仍然可以运行代码。 My question is if it is possible to change the command that is bound to Run Python File in Terminal .我的问题是是否可以更改绑定到Run Python File in Terminal的命令。 I could not find a solution to this in a couple hours of searching.我在几个小时的搜索中找不到解决方案。 Thanks in advance.提前致谢。

One solution I found was to reinstall the older python plugin and the "conda run -n" command would not be used at runtime.我找到的一种解决方案是重新安装旧的 python 插件,并且在运行时不会使用“conda run -n”命令。 Reinstallation method, Extension --> Python--manage--> install another version重装方法,扩展--> Python--管理--> 安装另一个版本

You're most likely running into a bug in conda 4.8 .您很可能在 conda 4.8 中遇到错误 You can either downgrade the extension until a point release comes out with a fix or simply wait for a fix (hopefully Monday).您可以将扩展降级,直到发布带有修复的点,或者只是等待修复(希望是周一)。

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

相关问题 Visual Studio Code Python 扩展“在终端中运行文件”不起作用 - Visual Studio Code Python extension 'Run File in Terminal' not working Visual Studio 代码(在终端中运行 Python 文件不起作用) - visual studio code (run Python file in terminal does not work) 如何在终端Visual Studio Code中运行Python3函数脚本 - How to run Python3 function script in terminal Visual Studio Code Microsoft Visual Code 中的差异“运行 python 文件”和“终端中的运行行” - Difference 'run python file' & 'run lines in terminal' in Microsoft Visual Code 带有 Visual Studio Code 的 Python - 运行特定文件 - Python with Visual Studio Code - Run specific file Visual Studio 代码:使用 arguments 运行 Python 文件 - Visual Studio Code: run Python file with arguments “Python:当前文件(集成终端)”——Visual Studio Code - "Python: Current File (Integrated Terminal)" - Visual Studio Code Visual Studio Code Python 终端更干净? - Visual Studio Code Python Terminal more cleaner? 有没有一种方法可以让命令提示符从 Visual Code Studio 运行 python 文件? - Is there a way that command prompt could run a python file from Visual Code Studio? 如何将我的 Visual Studio Code 终端上的 python 版本 2.7.16 更改为更新的 python 版本? - How change the python version 2.7.16 on my Visual Studio Code terminal to the newer python version?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM