1

So I need to use Python for my work. Unfortunately, since recent hacks, the companies security policies are very strict and there is no way I'm getting admin rights. I managed to persuade our IT to install Python, Visual Studio Code, and the Python extension for it on my computer.

If I try to run python commands in the Python interpreter it works. But when I try to run a Python script in Visual Studio Code it hast to run Power Shell which is also blocked for security reasons. I get the following error:

The terminal process command 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' failed to launch (exit code: {2})

Is there some way around this? To use Python in Visual Studio Code despite all of the security restrictions?

I tried asking our IT department but they have no idea how to help me...

Thank you in advance.

Bruno_BNF
  • 51
  • 4

2 Answers2

2

You can change the VS Code settings and tell it to not use PowerShell as shell in the integrated terminal.

For example, I have put Windows Terminal in there, but you can also use CMD or any other shell such a git bash as long as it's available in your system.

Press ctrl+shift+p and type/select Open Settings (JSON). Then add some of the following to this configuration file, and save.

For Windows Terminal:

"terminal.external.windowsExec": "C:\\Users\\<your-username>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

For CMD:

"terminal.external.windowsExec": "C:\\Windows\\system32\\cmd.exe"
The Fool
  • 16,715
  • 5
  • 52
  • 86
  • I love the simplicity of this solution but it's not working for me despite having followed the instructions to the letter :^( – Thadeu Freitas Filho Dec 31 '21 at 06:00
  • 2
    Sorry, I just realized the solution applied to external windows. I was looking for a solution to the integrated terminal. If so, the json code is `"terminal.integrated.defaultProfile.windows": "Command Prompt"` Works fine. – Thadeu Freitas Filho Dec 31 '21 at 07:25
2

I'm used below code in setting file and it works.

"terminal.integrated.defaultProfile.windows": "Command Prompt"
mkrieger1
  • 19,194
  • 5
  • 54
  • 65