Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

VSCode not running python files in terminal

I am running linux mint, current VSCode, python 3.8.5. Running VSCode through Anaconda navigator. I have a simple file "hello world" that when I right click the file from the left pane and choose "run python file in terminal" the terminal at the bottom of the screen pops up, but outputs no code and no error messages. When i choose the run triangle in the top right, same thing happens and no code is output and no error messages. When i right click the file in the left pane and choose to open the file in an interactive window, it will output the code. I am sure I am doing something wrong but I do not know what. 

 

Link to post
Share on other sites

I think you have to install an python extension to run python scripts.

Link to post
Share on other sites

What might be happening is that the console is closing as soon as your program ends, before you have a chance to see the output.

Try adding the following line to the bottom of your program: 

input()

This will cause your program to wait until you press the enter key in order to continue, and the console will stay open until your program ends (after you press enter).

Link to post
Share on other sites

I can just press the "Play" button (Ctrl+Alt+N) and it does run:

image.png.e01b9cf34445aeba932cfb714eb885bb.png

 

Right clicking the file on the left panel doesn't bring me any option like the "run python file in terminal" as you mentioned, but it may be due to the fact that I don't have Anaconda installed.

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to post
Share on other sites

It should not look like that. the ... next to output should have Terminal as an option. But the pulldown should not say Code but python.

I just have ms-python.python installed (just need the basic lint) and it will always switch to terminal when running.

Link to post
Share on other sites
8 hours ago, Dujith said:

It should not look like that. the ... next to output should have Terminal as an option. But the pulldown should not say Code but python.

I just have ms-python.python installed (just need the basic lint) and it will always switch to terminal when running.

It does with the coderunner plugin

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×