Python Question re Executing a Script

Dennis Lee Bieber wlfraed at ix.netcom.com
Sat Apr 30 19:44:56 EDT 2022


On Sat, 30 Apr 2022 22:37:35 +0000, Brent Hunter <brent at brenthunter.tv>
declaimed the following:

>Hello,
>
>I just purchased a new Windows 11 computer and installed Python 3.10.4 (64 bit).  I can't figure out from your documentation, how do I:
>
>
>  1.  Run a python script that is located in the same directory ( C:\Users\Brent\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.10 )
>

	ONE: that path indicates that you installed Python "for current user
only".

	TWO: that is the path for the short cut entry that shows up on the
Windows "Start Menu" (whatever that looks like on Win11). It is NOT a
location for user scripts.

	Python, at heart, is a language interpreter that is invoked from a
command line shell. (Use <ctrl-z> to exit the interpreter if you are trying
the below examples -- otherwise you'd add the path/name of the script file
to the command line)

-=-=-
Microsoft Windows [Version 10.0.19044.1645]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Wulfraed>python
Python ActivePython 3.8.2 (ActiveState Software Inc.) based on
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

C:\Users\Wulfraed>py
Python ActivePython 3.8.2 (ActiveState Software Inc.) based on
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

C:\Users\Wulfraed>
-=-=-

	It can run from scripts invoked by double-clicking on the file in the
"file explorer" but often the results are not as desired (it will pop up a
console window -- but that window closes as soon as the script exits!).
Scripts written using one of the graphical libraries (Tkinter, wxPython,
etc.) are typically given a .pyw extension -- .pyw is normally associated
with an alternate start-up module which suppresses the console window.

	Editing of scripts can be done with one's favorite programming text
editor. If one can't live without having some sort of IDE, look for
something called IDLE to be on your start menu (IDLE is actually a Python
script using Tkinter).

>
>  1.  How do I automatically run a python app at Windows startup?

	Short answer: the same way you would run ANY application at start-up. 

	Longer answer: this is a feature of the OS, not Python. You will need
to learn how to use the OS. Maybe start with
https://www.google.com/search?q=run+application+at+startup+windows+11&source=hp&ei=t1htYpm0K5OtqtsPiMKMwAc&iflsig=AJiK0e8AAAAAYm1mx0aL7YbWlEj0j-yPiL8J4H8HFoxo&ved=0ahUKEwjZ6-T3j7z3AhWTlmoFHQghA3gQ4dUDCAk&uact=5&oq=run+application+at+startup+windows+11&gs_lcp=Cgdnd3Mtd2l6EAMyBQghEKsCMgUIIRCrAjIFCCEQqwIyCAghEBYQHRAeOgUIABCABDoOCC4QgAQQsQMQgwEQ1AI6CAgAEIAEELEDOhEILhCABBCxAxCDARDHARDRAzoICC4QgAQQsQM6CwgAEIAEELEDEIMBOggILhCxAxCDAToFCC4QgAQ6EQguEIAEELEDEIMBEMcBEKMCOgsILhCABBDHARCjAjoICC4QgAQQ1AI6CwguEIAEELEDEIMBOgsILhCABBCxAxDUAjoOCC4QsQMQgwEQxwEQowI6DgguEIAEELEDEMcBENEDOg4ILhCABBCxAxCDARDJAzoICAAQsQMQgwE6BwgAEIAEEAo6CAgAEIAEEMkDOgYIABAWEB46BQgAEIYDUL0NWNRZYO9caAFwAHgBgAHYAYgBpx6SAQcyNC4xMi4xmAEAoAEBsAEA&sclient=gws-wiz

>
>Thank you!
>
>Brent Hunter


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


More information about the Python-list mailing list