[英]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.