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

Python SyntaxError: invalid syntax to repo init in the AOSP code

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

ERROR LOG

File "/xxx/.repo/repo/hooks.py", line 472
file=sys.stderr)
    ^
 SyntaxError: invalid syntax

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

Refer the given methods to solve the issue.

Method 1:

The issue could be a difference between your repo’s python version and my system’s python version. My repo is written in Python 2 and my system is written in Python 3. That is why I am experiencing this problem.

So, one possible solution is to upgrade the Python version in my repo to Python 3. This method worked for me.

Method 2 :

Try the below commands.

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

Hope the above solution works.

Also read :

AttributeError: Can’t get attribute ‘new_block’ on module Spark
NameError: name ‘re’ is not defined