Hello Guys how are you all ? Hope you all are fine. Today I Faced SyntaxError: invalid syntax to repo init in the AOSP code in Python.
When I an trying repo init the source code in VM Ubuntu machine. I Face Below Error in my Traceback.
Traceback (most recent call last): File "/xxx/.repo/repo/main.py", line 56, in <module> 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
Here I Have Defined All Possible Solution To Solve This Error.
Solution 1 : Install Python-3
Problem is might be difference between your repo python version and my system python version. my repo in python 2 and my system using python 3 version. That’s why I am facing this error.
So, Possible Solution is to update my repo’s Python version to Python 3. This Solution Was Worked For Me.
Solution 2 : Try Below Command Line.
Try this Given Command.
curl https://storage.googleapis.com/git-repo-downloads/repo-1 > ~/bin/repo chmod a+x ~/bin/repo python3 ~/bin/repo init -u [email protected]
This Command Might Solve your issue.
Solution 3 : Check Both System Python Version
Solution is…. you have to check your repo python version and Your system where you want to clone your code.
Just make sure you have to make sure both version must be same. So Your issue will be solve. here is github issue.
Solution 4 : Download Latest Repo and follow Below Command
- Download last version of repo :
curl https://storage.googleapis.com/git-repo-downloads/repo-1 > repo
- Change right to make it executable :
chmod a+x repo
- Run your repo init with python3 and the “repo” you just download :
python3 repo init -u [email protected]:xxx/xx_manifest.git -b xxx
Solution 5 : Change Below Lines
Just Modify the first line of /usr/bin/repo and change it from
This asks the system to use Python3 instead of the default Python. This Solution Is Worked For Me. Comment below if its work for you too.
So That’s it for Today SyntaxError: invalid syntax to repo init in the AOSP code in Python. Hope this above 3 solution might help you. Comment below your thought about this Solution. Thank You.