Powershell won't run program


I working on setting up my environment and am struggling getting a my first ex1.py program to run in power shell. I believe I have Python loaded correctly but it can not find the path when I execute to run the program. I have found a couple of solutions on the net but it has not fixed my problem yet after trying them. Any ideas?
I was recommended by Zed to:

Alright, so look at the top of your editor and what does it say where the file is saved?

c:\User\Brian\OneDrive\Documents\Python Programs\

Now look at your power shell and what does it say about where you are?


If you do an ls like this:


It will show you that your file isn’t there, because it’s in the place where the editor saved it. Do this:

After running I still have the same issue, PS can’t find the path


I also tried after google searches (both examples):


Defiantly on the struggle bus!

Hi @Brian1 I’m not on Windows right now, but it seems to me your problem stems from the space in your directory name Python Programs. Try to rename the directory to something like PythonPrograms or Python_Programs and try it again.

So your path should then look something like that:


Instead of:

C:\Users\Brian\OneDrive\Documents\Python Programs\

First close all your open files, etc. before you try it again.

Except one more thing, put quotes around any paths that have spaces in them:

cd "C:\Users\Brian\OneDrive\Documents\Python Programs\"

The reason why is that the command line thinks a space is a new work or argument. So it reads this:

C:\Users\Brian\OneDrive\Documents\Python Programs\

To mean:

Argument 1: C:\Users\Brian\OneDrive\Documents\Python
Argument 2: Programs\

One way to double check this is open the directory you want in Explorer, then just drag it into the PowerShell window. PowerShell will then write it out correctly for you. Works with files too.

1 Like

The Tab also auto fills. So from C:\Users\Brian\OneDrive\Documents\ type cd Pyt (TAB) and then '.\Python Programs\' should pop up (or what ever starts with Pyt, then just keep hitting Tab). It turns green i think. I cant tell up my screen right now.
After pressing Enter , you will cd into C:\Users\Brian\OneDrive\Documents\Python Programs\

Thanks for the help Neal, Zed, Didier!
I was finally able to get it to run my first exercise. Looking forward to learning more!

1 Like