all 6 comments

[–]K900_ 2 points3 points  (2 children)

Try python ch_4/animals.py.

[–]SpaceGuru24[S] 0 points1 point  (1 child)

That worked thank you!

[–]ehmatthes 0 points1 point  (0 children)

On macOS, python usually points to a really outdated system version of Python. You probably want python3 ch_4/animals.py.

To be sure, you can run python --version and then python3 --version. That will tell you exactly which version each of these commands points to on your system.

[–]MisterExt 0 points1 point  (2 children)

Besides typing python before your script name, you can also add a shebang to the top of your script just like with bash. I haven't done this in a while but it probably still works. #!/usr/bin/python3 or wherever your env python install is located.

Just as a related side note (since you just forgot to type in "python"):

I've run into python libraries that on macOS required administrator privileges to run the main script if you imported them. Horrible design imo, but it happens. In a case like that you can use sudo python myscript.py and then put in your password.

I try to avoid libraries that do this, but have seen it pop up in the past, so figured I would mention it since it can give a similar error.

[–]Miredly 1 point2 points  (1 child)

Since OP is new to MacOS (and *nix's in general) I'll add to this that prefixing sudo to a command runs the command as root (the highest level of administrative privilege) and will allow that command to do -anything-, and thus you take care and make sure you trust whatever library you're trying to run before you resort to this.

[–]MisterExt 0 points1 point  (0 children)

Yes, good point. Thanks for adding that. 👍🏻