Skip to content
Advertisement

Opening python files through cmd not working

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?

Advertisement

Answer

it’s usually:prompt> python filename.py

prompt should be the location of your python file: ex: c:usersdocumentspython 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?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement