Sublime Forum

Directory Issue Python (For Windows)

#1

Hi, I am new to all of this and need some help, please.
I have started my online Python course with Udemy. The first task is to run a simple code with Sublimetext, and then to save it to the Desktop as a ‘.py’ file: print(‘hello world’). I am able to save the file. However, when I open ‘command prompt’ and use the directory to get to my desktop, and then to run the file, it does not do so. it takes me back to the Desktop (as below), instead of running the code.

C:\Users\Claire Nieuwoudt\Desktop>python myexample1.py

C:\Users\Claire Nieuwoudt\Desktop>

Does anyone know what the problem could ?

0 Likes

#2

I am able to save a python file to the desktop & execute it by opening cmd & typing python main.py (or whatever happens to be the name of your file) (assuming you are on a windows machine)

I am also able to run the file and get the output via a build system. If you aren’t aware of it, you can simply press ctrl + b (on windows) and execute the python script directly from within sublime.

You can see from the GIF that I have saved a python file (main.py)

saved to desktop and pressing ctrl + b executes the code using the python build system and you can see the output below (remember that the build system targets the global python interpreter that you have installed).

If you want to learn more about build systems, this video does a good job of explaining it:
Build System Basics

It looks like your code was executed but there was no output. Are you sure that the file was saved properly & you just din’t execute an empty script ?

1 Like