unable to use python command in Terminal with Monterey v.12.6

Since installing Monterey on my MacBook Pro, I'm no longer able to the use "python" command plus a ".py" custom app in Terminal. I'm using Monterey v.12.6. When I try to run Terminal, I get a "permission denied" when I run python plus the .py app. How to do I restore the use of Terminal?

MacBook Pro

Posted on Oct 10, 2022 9:20 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 10, 2022 9:25 AM

The old python (version 2.7), which has long been deprecated, is no longer included with macOS since version 12.3


You can, however, install Python yourself.

I strongly recommend that you install a more current version - at present it is version 3.10.7.


Get it here: https://www.python.org/downloads/release/python-3107/


The page contains installers for various OS.

Choose the macos installer, of course.


Once installed, quit Terminal if it is running, then start it again and it should work.


4 replies
Question marked as Top-ranking reply

Oct 10, 2022 9:25 AM in response to DrD971

The old python (version 2.7), which has long been deprecated, is no longer included with macOS since version 12.3


You can, however, install Python yourself.

I strongly recommend that you install a more current version - at present it is version 3.10.7.


Get it here: https://www.python.org/downloads/release/python-3107/


The page contains installers for various OS.

Choose the macos installer, of course.


Once installed, quit Terminal if it is running, then start it again and it should work.


Oct 10, 2022 9:49 AM in response to DrD971

Your code is not fully compatible with Python 3.


If it is just little matters like this one, it is not hard to fix.


(and it is about time it was updated, too - it has been almost three years since Python 2 was "sunset")


As the error message indicates, print is a function, and as such it needs parentheses.


So, instead of


print fib(int(n))


it should be


print(fib(int(n)))


and likewise for any other print commands in the code - just wrap the arguments in a pair of parentheses.


If there are other issues, let us know.

And if this is not your own code, but someone else's, maybe they have an updated version.


Oct 10, 2022 9:42 AM in response to Luis Sequeira1

Thanks Luis. With the updated version of Python you recommended, when I run the "fib.py" app, I get the following error:

Last login: Mon Oct 10 12:32:32 on ttys000


DrD@Denniss-MacBook-Pro ~ % python3 /Users/DrD/Documents/Catherine\ LLC/Codes/Code\ Creation/fib.py  1052501


  File "/Users/DrD/Documents/Catherine LLC/Codes/Code Creation/fib.py", line 14


    print fib(int(n))


Any suggestions?


    ^^^^^^^^^^^^^^^^^


SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?


DrD@Denniss-MacBook-Pro ~ % 



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

unable to use python command in Terminal with Monterey v.12.6

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.