Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Missing parentheses in call to 'print' when running on Python3 #9

Open
marcomc opened this issue Aug 6, 2020 · 6 comments

Comments

@marcomc
Copy link
Contributor

marcomc commented Aug 6, 2020

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?

@christhekeele
Copy link

The README does claim python 3.6 is required, is that not accurate? Having this issue as well.

@tillydray
Copy link

@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

@marcomc
Copy link
Contributor Author

marcomc commented Oct 2, 2021 via email

tillydray added a commit to tillydray/macprefs that referenced this issue Oct 2, 2021
@clintmod
Copy link
Owner

Ya sorry it's python 2.

@Bobronium
Copy link

Bobronium commented Jun 21, 2022

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 

@ghost
Copy link

ghost commented Sep 10, 2023

I got the same error, How do i resolve this. Please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants