Linojan
Linojan

Reputation: 168

How do i run python file in cmd from vscode

I have a python program which prints long outputs. When i try to run that file in vscode, its interactive window isn't enough to view full output. So is there any way to run python file in cmd from VSCODE?

Upvotes: 3

Views: 15583

Answers (2)

bart cubrich
bart cubrich

Reputation: 1254

As @Jeremiah said, you can also just run your script with the Cmd prompt, without using vs code. Let's say you have the file 'test1.py' saved as C:\Users\bcubrich\Documents\test1.py, and your python env .exe is saved in C:\python27\ArcGIS10.5\python.exe. I just wrote script that had this in it:

print('worked')

Then just input this into the Cmd prompt

C:\python27\ArcGIS10.5\python.exe C:\Users\bcubrich\Documents\test1.py

And it printed

worked

to the console.

More on running python through cmd console here: http://www.cs.bu.edu/courses/cs108/guides/runpython.html

Upvotes: 0

user10597469
user10597469

Reputation:

If you are running windows, VSCode uses Powershell as your terminal by default. If you want to use the command prompt instead, hit ctrl+shift+p, type Shell into the command pallet, select Terminal: Select Default Shell, and change it to Command Prompt. I am not sure this will fix your problem as I think Powershell should display just as much output as the CMD, but if you want to try switching terminals, that will do it. Another option is to try to run it natively in CMD or Powershell, rather than using the VSCode integrated terminal. That might be better if changing terminals doesn't help.

Upvotes: 7

Related Questions