3

path information

I want to run python files through cmd (python 3) from my desktop by using this command:

python HelloWorld.py

I have made sure to click on all the ok buttons when adding a path, I had the python installation automatically add paths so python works through the terminal. It just won't do it without me pasting in the path manually every time.

P.S.: What do python developers usually use? A text editor and run it through cmd or something like pycharm?

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Po Chen Liu
  • 253
  • 2
  • 12

2 Answers2

1

it's usually:prompt> python filename.py

prompt should be the location of your python file: ex: c:\users\documents\python this is the preferred way.

if this doesn't work you may not have added python to path. when initially installing python, you will get an option that says "add to path" make sure you check this. just reinstall python if you have this problem.

I'm 99% sure you're not trying to run the script as an executable, but just in case you are, here is a related thread:

How can I create a directly-executable cross-platform GUI app using Python?

algorythms
  • 1,547
  • 1
  • 15
  • 28
  • Is there a way to change the location of the default directory so that when I open it, it always starts on desktop? – Po Chen Liu Jan 30 '19 at 23:59
  • 1
    go to directory where cmd prompt exe is located. right click, select properties, find option "start in" and you can set your default directory here. – algorythms Jan 31 '19 at 00:14
  • if my main answer thread above was helpful, would you mind upvoting it? I'm new here and it would help me a lot. Thanks! – algorythms Nov 26 '19 at 05:48
0

if you get the error:

No such file or directory

then you need to be in the same directory as your file, first use

cd c:\Users\(username)\Desktop

(replace (username) with your username)

this should put you on your desktop, then use:

python HelloWorld.py
LonelyDaoist
  • 665
  • 8
  • 22