Link to home
Start Free TrialLog in
Avatar of whales8888
whales8888

asked on

I cannot see result of code in DEBUG or anywhere within Visual Studio Code of a coding exercise in Python3. I have a business, but am learning Python3 as a means of better understanding what it can do

THE PROBLEM: I cannot see result of code in DEBUG or anywhere within Visual Studio Code of a coding exercise in Python3.

I have installed python and Visual Studio Code on my laptop running Windows 10, Version 1803 OS build 17134.706.
I have an ASUS ROG  laptop with 16 GB RAM and 1 TB drive, 64 bit processor and operating system

I am subscribing to Lynda to learn Python and am using the course developed by Joe Marini entitled Learning Python  (I am a beginner).

I am using Python 3.7 (32 bit)

I have installed the plugin extension from Microsoft so can run Python apps in VSCode. I am using extension: Python 2019.4.12954 Linting, Debugging (multi-threaded remote),… Microsoft.

I am using the exercise files included, i.e., I am trying to run or see code and code output in Debug in VSCode .

I have exercise files open and clicked on the specific file I wanted to see. I did the following:
       I clicked on Debug Icon.

      Under the Debug dropdown I chose: "My Current File (Integrated Program)"  

Next, I chose the exercise file named helloworld_start.py with the following and the following code appeared in the VSCode window

#
# Example file for HelloWorld
#
def main():
  print("hello world")
if __name__ == "__main__":
main()

I then clicked on the Debug Arrow and I got the following in the terminal window within VSCode:

D:\Main 2\Training\Programming\PYTHON_Joe_Marini_Release-18__0130\Ex_Files_Learning_Python\Exercise Files>cd "d:\Main 2\Training\Programming\PYTHON_Joe_Marini_Release-18__0130\Ex_Files_Learning_Python\Exercise Files" && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && "C:\Program Files\Anaconda3\python.exe" c:\Users\-\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 59185 "d:\Main 2\Training\Programming\PYTHON_Joe_Marini_Release-18__0130\Ex_Files_Learning_Python\Exercise Files\Ch2\helloworld_start.py" "

D:\Main 2\Training\Programming\PYTHON_Joe_Marini_Release-18__0130\Ex_Files_Learning_Python\Exercise Files>

I am trying to get or see somewhere the following: hello world

Can you help me identify what I am doing wrong?
Avatar of Peter Hutchison
Peter Hutchison
Flag of United Kingdom of Great Britain and Northern Ireland image

On my mac I had to install python 3.7.3 and then in VS Code installed the required extensions to run the program.

1. Load up VS Code
2. Load up you helloworld_start.py.
   (If you have multiple versions of python installed, add the following line to the start of the program, to ensure python3 is used
    #!/usr/bin/python3
   Also, make sure only lines 7 and 10, in the code,  are indented by two spaces. Other lines should start in column 1.
3. Click on View menu, and select Output to view any output from program.
4. On the left hand side, click on the Debug icon (4th icon down) to view Variable, Watch, Call Stack and Breakpoints.
5. In the output window, enter 'clear' to clear window contents.
6. On Debug menu, select Start Debugging and select 'Python file. Debug the currently active Python file'
7. The output 'hello world' will appear in the output or terminal window.
Avatar of whales8888
whales8888

ASKER

THANKS, Peter. I will try as soon as I get time.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.