Python Forum
to call via console a python-programm
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
to call via console a python-programm
#1
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?
Reply
#2
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.
Reply
#3
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]
Reply
#4
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?
Reply
#5
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.
Reply
#6
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
Reply
#7
[Image: irdFuTC.jpg]
Reply
#8
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.
Reply
#9
Thank you. So was it solved:

[Image: vz65ow3.jpg]
Reply
#10
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  In Console,Python anna17 0 133 Mar-23-2024, 08:24 PM
Last Post: anna17
  embed python script in C programm gucio321 0 580 Feb-11-2023, 10:47 AM
Last Post: gucio321
  Python Flask Realtime system printout (console) ffmpeg jttolleson 3 2,858 Apr-18-2022, 06:39 PM
Last Post: jttolleson
  Python library for win32 console commands eldiener 3 3,384 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Problem: Restart kernel onPydev console when trying to install a python package poppy2020 1 7,558 Nov-25-2020, 06:13 PM
Last Post: Larz60+
  My Python Console doesn´t work ModuleNotFoundError: No module named 'tokenize' RuanKishibe 1 3,071 Aug-06-2020, 10:07 PM
Last Post: deanhystad
  Adding colour to Python console Archangelos 4 2,685 Apr-15-2020, 05:15 PM
Last Post: newbieAuggie2019
  how to get some values from js on python console by python code vivekagrey 1 1,834 Feb-13-2020, 09:26 PM
Last Post: micseydel
  I don't know what's wrong with this code [Python Console] H0M1C1D4L_P1G 6 3,130 Dec-22-2019, 10:27 PM
Last Post: snippsat
  Call pip3 from python folder build by me call pip3 from the /usr/bin Suryavarman 3 3,622 Oct-07-2019, 10:23 PM
Last Post: Suryavarman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020