Beginner: How do you run a Python program? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Beginner: How do you run a Python program? (/thread-22460.html) |
Beginner: How do you run a Python program? - StephenG1CMZ - 10-07-2024 03:02 PM Now that Python has finally reached HP Prime Android, after several years on the actual calculator, perhaps those more experienced can give beginners a few clues. Here's what I have discovered so far: It seems to be micro python 3.4. Upon entering the App, ignore "Save" and "Load" menus - they don't save and Load files. Press "Symbol" to see programs, and you will see a "More" menu. That's where you will find Files you have created. (They are separate from PPL and CAS programs). Press "Num" to see earlier program results. After editing a program, when you re-enter Python App you may be asked if you want to run edited files. Selecting Yes flashes some output on the screen and the App crashes back to Android. Is this a bug? Restarting the calculator and Python gets you back to the point where you can press "Symb" to see files...there's no "run" menu (by comparison, PPL has both Run and Debug). I have seen program output, but it is not clear how best to reliably run a program (hence I can't yet confirm the Python version number). Syntax errors give a line number, but don't drop you into an edit screen. Once past these beginners hurdles, there is an impressive range of modules (but no numpy). It seems it can even read data files - very rare if not unique on calculator implementations. A "getting started" guide would be a great help. RE: Beginner: How do you run a Python program? - StephenG1CMZ - 10-07-2024 04:25 PM It seems there are a few solutions to running the program in this thread: https://www.hpmuseum.org/forum/thread-20496.html?highlight=Python+app RE: Beginner: How do you run a Python program? - komame - 10-07-2024 05:42 PM The HP Prime currently has an implementation of Micropython version 1.9.4, which can be checked with: Code: import sys The latest version of Micropython is currently 1.23.0 [doc]. There is no such thing as Load and Save menus in the Python App. These menus are simply in the Home view, regardless of the active application. They allow for saving and loading the history of calculations (the history stack). As for the syntax error and jumping to the line of the program where the error occurred, this has worked correctly since Python has been available on the HP Prime (a popup with error information appears, and when you click OK, it takes you to the line where the error occurred). When the Python application is active, pressing Symb allows you to enter your program, and then pressing Num and confirming file imports, you can run it. Pressing OK for confirmation should not cause a reset/restart; this may be a bug in the Android version. You can also create your own application (with an icon in the Application Library) that will immediately run your program without the need to switch between Symb and Num. Mike (ab3ap here) has prepared a nice tutorial for beginners, and I think it's worth reading. If you have any specific questions about Python on the HP Prime, feel free to ask. RE: Beginner: How do you run a Python program? - StephenG1CMZ - 10-08-2024 01:50 PM After uninstalling and reinstalling the app, it now seems to run the program upon re-entering the python app (I'm now using main.py rather than tryp.py, if that makes a difference). And syntax errors now offer to take you to the edit line. Seems much better now. RE: Beginner: How do you run a Python program? - StephenG1CMZ - 10-08-2024 05:05 PM Unfortunately that ease of running Python was only temporary. Since importing code from the mobile, the difficulties have returned. Tried another reinstall, but that hasn't helped. (update: a 2nd reinstall helped briefly) Python says files have changed, do you want to run? Ok flashes up an import screen and crashes. Can Python run scripts imported from Android mobiles? Deleting the imported code doesn't help, it still crashes. RE: Beginner: How do you run a Python program? - Thomas_Sch - 10-09-2024 11:20 AM There's a great video from HHC 2023, by Günter Schink "HHC 2023: Python on Prime: A Personal Experience (Günter Schink)" in YT. https://www.youtube.com/watch?v=-PLt2khyAik |