Hi all, nice to find out there is a nice community of people out here to read about. I have a simular problem to this post: Python: command not found . Also trying to use VS code on a Mac, and also having tried HomeBrew and other solutions. I tried the solutions in the comments - such as the python intepreter. But no such luck. If anyone could help, that would be really great, as Ive read some other stuff online, but I dont want to go about willy nilly.
Additionally, if anytone has some other advice to starting fresh with python, I would be appreciative.
I don’t see where you came back to let anybody know whether or not you got the first problem fixed.
Getting python installed and running was simple enough (for me) under Linux and Windoze.
One of my first problems was the program opening and closing before I could see it. To fix that I added an ‘quit = input(“: press enter to quit.”)’ line. This makes the ‘console window’ hang around while I read what the output was. Then quit the program when I pressed the enter key.
# How to check data
numo1 = int(input("Enter the first number: "))
numo2 = int(input("Enter the second number: "))
try:
print(": divide first by second = ", numo1 / numo2)
except:
print("This operation cannot be done.")
print(": THE END.")
quit = input(": press enter to quit.")
However, I find it a lot easier and faster to simply double click the script and let the OS start up Python and the window to display the results . . than opening a terminal window then typing in a run command.
I’ve since learned to use Tkinter . . and I like it. A Lot.
Barry > You have code that is does not have a GUI windowed interface.
That is too true, Barry.
Windows would open a terminal window for me, run the program in it, then disappear before I could read it. Hence, the need to add an ‘input line’ which would keep the window open till I was ready to quit.
There were baby programs I was writing - solely to learn how to implement things like for-loops, slicing chunks out of the middle of a string, or calling up the Math package. For little things like that . . . why mess with a GUI interface?
Now I am using Tkinter. I have a couple of programs that I use for my own purposes that I am happy with. (One solves quadratic equations - Python does not mind giving me imaginary numbers in the results.)
But, if my grandsons decide to learn some computer programming . . . I have a Linux box and I’ve learned about setting permissions and that ‘hashbang’ thing.
And, running it from a terminal window . . Click to open the terminal window . . type in the command python3.8 myprogr.py . . . Versus simply opening the sub-directory and double clicking the file. No contest - I’d rather just double click the file like I do everything else.
Check your path variable on the Mac OS. To do that open a terminal window, go to your project directory, type python -V. To check your path variable on Mac in the terminal I think it is echo $PATH.
In my Windows I have a batch file which I update and use with all my tools called addpath.bat and I add my path there. It’s a very long path.
The problem with that is that when your program break and prints a traceback you will only see the Window flash up and vanish without letting you read the traceback.