Making it work with macOS Monterey 12.3 -- which has python2 removed and supports only python3
I had trouble making this work on M1 Macbook with macOS Monterey 12.3.
Error -- sudo: /usr/bin/python: command not found
Reason -- Apple is removing support for Python2 from this release (12.3) onwards.
Solution -- make the code work for Python3
Files location -- /opt/homebrew/bin/auto-selfcontrol and /opt/homebrew/bin/auto-selfcontrol.py
- Changing the file "auto-selfcontrol"
line 55 -- change
sudo /usr/bin/pythontosudo /usr/bin/python3
- Changing the file "auto-selfcontrol.py"
change
print()on line 87 and line 132. changehas_keyto__contains__on line 343, line 352 and line 361.
edit the
get_osx_usernames()function on line 348 by - adding.decode()at the end of line 385 to process the 'b' put by Python3 in front of strings. changingoutput = subprocess.check_output(["dscl", ".", "list", "/users"])tooutput = subprocess.check_output(["dscl", ".", "list", "/users"]).decode()
edit the
get_launchscript()function to run Python3 --<string>/usr/bin/python</string>to<string>/usr/bin/python3</string>
The script runs without any errors after the above changes, however, many other changes might also be required for uncaught exceptions to make the script run from 12.3 onwards. In the meantime, someone please push the above changes to this repo.
Also, the script does run without errors. But it does not work properly -- it does not block (issue 64)
Also
auto-selfcontrol install shows
Detected API v2 Start installation of Auto-SelfControl Removed previous installation files Save run configuration Installed
Why does it show API v2. Shouldn't it be API v3 since I am running SelfControl Version 4.0.2 (410)?
Thanks for the help. I've added your recommendations and the ones from #28. My local tests were successful but they are still on a branch. Until we found a solution for #64, it is not of much use anyway. When we solve this issue, we can build a new major version with the changes from the python3 branch.
Is there a workaround yet? I can't seem to make auto-selfcontrol work.
I've tried the changes suggested but it doesn't work.
I hope that we can get some solution for this, I can not make it run :(