SyntaxError: Missing parentheses in call to 'print' when running on Python3
The requirements say Python 3.6.0 is required but in reality, it looks like the code has been written with Python2 standards in fact if I run the application with Python 3.x it fails as follow:
python /usr/local/bin/macprefs restore
File "/usr/local/bin/macprefs", line 23
print 'Backup Complete.'
^
SyntaxError: Missing parentheses in call to 'print'
if I run it in Python 2 it works fine
are you planning to adapt the code?
The README does claim python 3.6 is required, is that not accurate? Having this issue as well.
@clintmod any guidance here? I'm having the same issue
$ python --version
Python 3.9.7
$ macprefs backup
File "/usr/local/bin/macprefs", line 23
print 'Backup Complete.'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Backup Complete.')?
But when I uninstall python3, I get this
$ python --version
Python 2.7.16
$ macprefs backup
Backing up system preferences...
Backing up start up items...
Error Info:
error code = 23
cmd ['rsync', '-a', '/Library/LaunchDaemons/', '~/Sync/MacPrefsBackup/StartupItems/LaunchDaemons/AllUsers/']
error message:rsync: send_files failed to open "/Library/LaunchDaemons/com.microsoft.teams.TeamsUpdaterDaemon.plist": Permission denied (13)
rsync: send_files failed to open "/Library/LaunchDaemons/net.privatetunnel.ovpnagent.plist": Permission denied (13)
rsync error: some files could not be transferred (code 23) at /System/Volumes/Data/SWE/macOS/BuildRoots/38cf1d983f/Library/Caches/com.apple.xbs/Sources/rsync/rsync-55/rsync/main.c(996) [sender=2.6.9]
Traceback (most recent call last):
File "/usr/local/bin/macprefs", line 73, in <module>
main()
File "/usr/local/bin/macprefs", line 69, in main
invoke_func(args)
File "/usr/local/bin/macprefs", line 39, in invoke_func
args.func()
File "/usr/local/bin/macprefs", line 17, in backup
startup_items.backup()
File "/usr/local/Cellar/macprefs/1.0.26/bin/startup_items.py", line 10, in backup
backup_system_daemons_agents()
File "/usr/local/Cellar/macprefs/1.0.26/bin/startup_items.py", line 35, in backup_system_daemons_agents
copy_dir(source, dest)
File "/usr/local/Cellar/macprefs/1.0.26/bin/utils.py", line 31, in copy_dir
execute_shell(command)
File "/usr/local/Cellar/macprefs/1.0.26/bin/utils.py", line 12, in execute_shell
cwd=cwd, stderr=STDOUT).strip().decode("utf-8")
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 223, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['rsync', '-a', '/Library/LaunchDaemons/', '~/Sync/MacPrefsBackup/StartupItems/LaunchDaemons/AllUsers/']' returned non-zero exit status 23
Use python 2.x
On Sat, 2 Oct 2021 at 11:58, Jason @.***> wrote:
@clintmod https://github.com/clintmod any guidance here? I'm having the same issue
$ python --version Python 3.9.7 $ macprefs backup File "/usr/local/bin/macprefs", line 23 print 'Backup Complete.' ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Backup Complete.')?
But when I uninstall python3, I get this
$ python --version Python 2.7.16 $ macprefs backup Backing up system preferences... Backing up start up items... Error Info: error code = 23 cmd ['rsync', '-a', '/Library/LaunchDaemons/', '~/Sync/MacPrefsBackup/StartupItems/LaunchDaemons/AllUsers/'] error message:rsync: send_files failed to open "/Library/LaunchDaemons/com.microsoft.teams.TeamsUpdaterDaemon.plist": Permission denied (13) rsync: send_files failed to open "/Library/LaunchDaemons/net.privatetunnel.ovpnagent.plist": Permission denied (13) rsync error: some files could not be transferred (code 23) at /System/Volumes/Data/SWE/macOS/BuildRoots/38cf1d983f/Library/Caches/com.apple.xbs/Sources/rsync/rsync-55/rsync/main.c(996) [sender=2.6.9]
Traceback (most recent call last): File "/usr/local/bin/macprefs", line 73, in
main() File "/usr/local/bin/macprefs", line 69, in main invoke_func(args) File "/usr/local/bin/macprefs", line 39, in invoke_func args.func() File "/usr/local/bin/macprefs", line 17, in backup startup_items.backup() File "/usr/local/Cellar/macprefs/1.0.26/bin/startup_items.py", line 10, in backup backup_system_daemons_agents() File "/usr/local/Cellar/macprefs/1.0.26/bin/startup_items.py", line 35, in backup_system_daemons_agents copy_dir(source, dest) File "/usr/local/Cellar/macprefs/1.0.26/bin/utils.py", line 31, in copy_dir execute_shell(command) File "/usr/local/Cellar/macprefs/1.0.26/bin/utils.py", line 12, in execute_shell cwd=cwd, stderr=STDOUT).strip().decode("utf-8") File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 223, in check_output raise CalledProcessError(retcode, cmd, output=output) subprocess.CalledProcessError: Command '['rsync', '-a', '/Library/LaunchDaemons/', '~/Sync/MacPrefsBackup/StartupItems/LaunchDaemons/AllUsers/']' returned non-zero exit status 23 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/clintmod/macprefs/issues/9#issuecomment-932766018, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK4ZSBTVPVBBACU7HKHVITUE4MZFANCNFSM4PW6CPOA .
-- Marco Massari Calderone
Ya sorry it's python 2.
I was able to get it working with python 3 by converting it with 2to3 tool and changing one line:
entrypoint=$(readlink -f $(which macprefs)) \
&& sudo 2to3 -W -n $entrypoint $(dirname $entrypoint) \
&& before=$(cat $entrypoint) \
&& sed 's/== "None"/is None/' $entrypoint | sudo tee $entrypoint | diff <(echo $before) -
Works:
macprefs
macprefs --help
macprefs --version
macprefs backup
Doesn't work:
macprefs --verbose backup # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 382: invalid continuation byte
Haven't tried:
macprefs restore
macprefs --verbose restore
I got the same error, How do i resolve this. Please help