Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Operation Not Permitted
#1
Hi, per my username I'm relatively new to python ;-)

I have a new Mac and when I attempt to run a python script via cron, I receive the following error:

/Library/Developer/CommandLineTools/usr/bin/python3: can't open file '/Users/mi/Downloads/Scripts/TestFile.py': [Errno 1] Operation not permitted

I'm logged in as user mi

The file has the following permissions: -rwxr-xr-x@

When I execute the file manually from the terminal, it runs successfully.

Cronjob is the following:
* * * * * /usr/bin/python3 /Users/mi/Downloads/Scripts/TestFile.py >> ~/Downloads/Scripts/TestFile.log 2>&1

Side Note, when I do run it manually from the terminal, even though it runs successfully, it shows the following message:
/Users/mi/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020

I'm not sure if the above message has any impact on the "Operation Not Permitted" issue

When I run "python3 --version" it returns Python 3.9.6
When I run "which python3" it returns /usr/bin/python3
When I run $PATH, it shows the following:
/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/mi/Library/Python/3.9/bin:/Users/mi/Downloads/Scripts:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin

Any ideas why it might be working locally but not from the cronjob? Any guidance would be greatly appreciated!
Reply
#2
Looks like it's probably not a python thing but that cron might need special permissions on Mac.
https://apple.stackexchange.com/question...-permitted
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Errno 1] Operation not permitted whois1230 8 53,546 Jun-12-2020, 11:57 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020