Skip to content
Home » SyntaxError: invalid syntax to repo init in the AOSP code

SyntaxError: invalid syntax to repo init in the AOSP code

To solve SyntaxError: invalid syntax to repo init in the AOSP code error follow below methods.

ERROR LOG

from subcmds.version import Version
 File "/xxx/.repo/repo/subcmds/__init__.py", line 38, in <module>
['%s' % name])
 File "/xxx/.repo/repo/subcmds/upload.py", line 27, in <module>
from hooks import RepoHook
File "/xxx/.repo/repo/hooks.py", line 472
file=sys.stderr)
    ^
 SyntaxError: invalid syntax

How to solve SyntaxError: invalid syntax to repo init in the AOSP code error ?

The issue, I believe, is the Python version. So, using python3, run the repo init command, and the repo you just downloaded will solve your problem.

Simply execute the command listed below.

curl https://storage.googleapis.com/git-repo-downloads/repo-1 > ~/bin/repo
chmod a+x ~/bin/repo
python3 ~/bin/repo init -u git@....

This solves your problem. For clear understanding refer below steps:

  1. Download last version of repo : curl https://storage.googleapis.com/git-repo-downloads/repo-1 > repo
  2. Change the repo rights to make it executable : chmod a+x repo
  3. Run your repo init with python3 and the “repo” you just download : python3 repo init -u git@github.com:xxx/xx_manifest.git -b xxx

Fix SyntaxError: invalid syntax to repo init in the AOSP code error if the Python version is correct

If the python version is correct then One of the way is to modify the first line of /usr/bin/repo and change it from :

#!/usr/bin/python

to

#!/usr/bin/python3

Hope the above solution works.

Also read :

Error: Node Sass version 5.0.0 is incompatible with ^4.0.0.
Warning: /opt/homebrew/bin is not in your PATH Installing Homebrew On Macos Big Sur