Python Forum

Full Version: to call via console a python-programm
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to call an in Python frish-written programm zeit_01 via console.
It didn't run. What I did false?:

[Image: Wp6wDxY.jpg]

one step more:

[Image: lMXUVA3.jpg]

How do it right?
Your PATH has to have a directory that contains the installed python executable like python3.exe or python.exe, not your project or .py files.

It looks like you've changed PATH to something else and now it can no longer find python.

Try opening a new cmd window and run python -V. It should show a version number and then you can try to run your program.
Thank you.

(Nov-21-2020, 01:27 AM)bowlofred Wrote: [ -> ]Try opening a new cmd window and run python -V. It should show a version number and then you can try to run your program.

[Image: Y0GywRL.jpg]

and?
I would like to open the existing programm zeit_01.py I do it like described in the book (s. screenshot before), but it doesn't run so... Wall

here is hte PARTH and file python.exe (or pytonw.exe? I'm using also PythonWin):

[Image: DOdIYgY.jpg]
I think so I've called the python3.9.0 via console:

[Image: VxXx98s.jpg]

I would like to ask how could I call the file zeit_01.py via console?
Go into the directory where the file is and run C:> python zeit_01.py. Python will be found because it is in your PATH; zeit_01.py will be found because it is in your current directory.
The file zeit_01 is here:

[Image: 3MtzS3F.jpg]

and I did so:

[Image: e7QJoXK.jpg]

but...

In the book are followed additional options offered:

C:\python\...project...> /python3/python zeit_01.py

or

C:\python\...project...> py -3.9 zeit_01.py
[Image: irdFuTC.jpg]
The default installer will also create a py.exe in your path. You can use that instead if you prefer.

The >>> string is the prompt from the interactive python interpreter. You can type python commands, but that's not how you run python scripts. Run them from the C:> prompt. Are you typing the "C:\Python39...." stuff? That should just be a prompt, not the part you type.

C:\> py zeit_01.py
or
C:\> python zeit_01.py
Note no ">>>" in the prompt.
Thank you. So was it solved:

[Image: vz65ow3.jpg]
If python is in your path, you shouldn't need the full name to python, just "python".

If you are in the directory with your program, you don't need the full path to your script.

Both are fine, but I would normally be trying to shorten the amount of typing I have to do.