G+_Rud Dog Posted September 11, 2015 Share Posted September 11, 2015 Been playing around with Python3 on my Windows 7 machine for about a month or so and just realized I don't yet know how to be able to package a script file. By that, what is meant, turn short script into something I can use from my desktop with out having to open IDE. Do all Python scripts have to be run from the command line? Right now if I double click on my script icon it opens Pryscripter which is the association assigned. Have heard of running under GUI converter but have not figured that one out as of this day. Link to comment Share on other sites More sharing options...
G+_Eddie Foy Posted September 11, 2015 Share Posted September 11, 2015 Not sure how Windows does it. But if this works from a command line: python Just make a batch file for it. (just mind the paths) Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted September 11, 2015 Author Share Posted September 11, 2015 How would I give this short search by keyword script to my grandmother and have her run it? She has XP but if I gave it to my father-in-law he is running Windows 7? Can this be packaged Newbie-friendly? Link to comment Share on other sites More sharing options...
G+_Eddie Foy Posted September 11, 2015 Share Posted September 11, 2015 Could use IE Express (MS product) to package up an installer. Its actually fairly easy to use, not too many 'gotchas/quirks' Link to comment Share on other sites More sharing options...
G+_Ben Reese Posted September 11, 2015 Share Posted September 11, 2015 If the path to Python is in the %path% environment variable, you can run that "python scriptFile.py" from anywhere. The Python installer may add itself by default. Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted September 11, 2015 Author Share Posted September 11, 2015 Eddie Foy What would I include in the installer my script and a copy of Python3? Ben Reese The script I created is called KWS.py (KeyWordSearch). Checked the %PATH% variable and both the path to Python executable and my scripts folder are listed. Scripts folder is where I place my scripts once completed. Not sure I understood what you meant by "from anywhere"? We talking from dos-cmd window, python command line? Tried both and it failed to find the script. At this point not sure how to run python scripts with out IDE, forget grandma and F-I-L. Link to comment Share on other sites More sharing options...
G+_Eddie Foy Posted September 11, 2015 Share Posted September 11, 2015 Been a while since I used IE Express. But I just had a .bat file moving everything around. Also a vbscript doing its setup thing too (registry edits and such). If Python3 is a msi file, you should be able dump it in the package too. (I'm not in Windows much, and then its usually hit and run) 'From anywhere' means it in the path and you do not have to type out the full pathname (ie: python c:\users\somedude\mypython\scripts\todays-scripts\dosomething.py) you can just type python dosomething.py Link to comment Share on other sites More sharing options...
G+_Black Merc Posted September 12, 2015 Share Posted September 12, 2015 For grandma... compile to an exe with a window prompt to input variables for a bat file... call the ide + script + (%1 %2 %3 ...) (%1... for variables following .bat file) command line or run prompt only MHO? Link to comment Share on other sites More sharing options...
G+_Ben Reese Posted September 12, 2015 Share Posted September 12, 2015 Yeah, by "from anywhere" I mean from any folder. If you have a bat file on your desktop that calls python, it will first look for the Python executable on your desktop (a folder on C-drive) then it will check all the folders in the path variable. If you just updated %path% with the folder holding your script, you'll probably need to reboot. There's some other script you can run to refresh Windows with the new paths, but I don't know what it is. I also remember a coworker compiling his Python code to a Windows executable. I don't pay attention to what he did to compile it, but for Grandma it will probably worth looking into. Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted September 12, 2015 Author Share Posted September 12, 2015 Eddie Foy , my next deep research project is going to include using Windows installer. Black Merc been awhile since have played with Batch files looks like this bat file will first open IDE or what ever program you wish to run the script in then run the script then see what arguments you have entered . Will review and see if I can get this to work assuming the way you wrote it is the correct syntax? Ben Reese after reading your input it sounded like you thought I had just changed the PATH variable to what I mentioned in my response but on the contrary this has been the case since installing Python a few months ago. As for the compiling the script I just downloaded py2exe and am learning how this functions. Link to comment Share on other sites More sharing options...
G+_Josh Wassing Posted September 12, 2015 Share Posted September 12, 2015 Been wondering about this myself Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted September 12, 2015 Author Share Posted September 12, 2015 After downloading py2exe and reading up on how to use it was successful in getting 2 out 3 scripts to run via DOT-EXE file. One thing looking for some kind of info on is how to keep the DOS prompt window open after it completes scripts. Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted September 16, 2015 Author Share Posted September 16, 2015 Py2exe worked for my Python 3 scripts enough so to try on a different machine then my own but it also had Python3 loaded but was successful. Link to comment Share on other sites More sharing options...
Recommended Posts