Visual Studio代码cmd错误:无法加载,因为此系统上的运行脚本被禁用 [英] Visual studio code cmd error: Cannot be loaded because running scripts is disabled on this system

查看:367
本文介绍了Visual Studio代码cmd错误:无法加载,因为此系统上的运行脚本被禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio代码中,我试图从命令行执行script.bat,但出现以下错误:

Inside of visual studio code, I'm trying to execute a script.bat from the command line, but I'm getting the following error:


文件C:\Theses_Repo\train-cnn\environment\Scripts\activate.ps1无法加载,因为此系统上的运行脚本已禁用。

File C:\Theses_Repo\train-cnn\environment\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system.

阅读我试图在管理员模式下运行Visual Studio代码,以为问题出在特权上。但是无论如何都会抛出错误。

After reading this I tried to run the visual studio code in administrator mode, thinking that the problem was a matter of privileges. But the error is throwing anyway.

推荐答案

我发现此处,您可以将其添加到 Visual Studio代码设置以下内容,问题将消失:
对于Visual Studio代码设置,请转至File->首选项->设置->扩展名->向下滚动并找到在settings.json中编辑。 不要忘记重新启动Visual Studio代码

I found out here that you can add to your visual studio code settings the following and the problem will vanish: For visual studio code settings, go to File -> Preferences -> Settings -> Extensions -> Scroll down and find "Edit in settings.json". Do not forget to restart the visual studio code

"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]

原因是,在像Visual Studio代码这样的构建命令行集成中,需要自行设置命令行策略。通过设置以上配置,Visual Studio代码将为您完成此操作。

The reason is that, in build command line integrations like visual studio code, you need to set the command line policies by your self. By setting the above configurations, the visual studio code will do that for you.

(请阅读,以便更好地了解命令行策略)

(read this to understand better the command line policies)

这篇关于Visual Studio代码cmd错误:无法加载,因为此系统上的运行脚本被禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆