Skip to content

Making it work with macOS Monterey 12.3 -- which has python2 removed and supports only python3 #65

@himanshubabal

Description

@himanshubabal

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

  1. Changing the file "auto-selfcontrol"

line 55 -- change sudo /usr/bin/python to sudo /usr/bin/python3

  1. Changing the file "auto-selfcontrol.py"

change print to print() on line 87 and line 132.
change has_key to __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.
changing output = subprocess.check_output(["dscl", ".", "list", "/users"]) to output = 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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions