SyntaxError: invalid syntax to repo init in the AOSP code
Are you are learning about “SyntaxError: invalid syntax to repo init in the AOSP code“? In today’s article, I will provide solutions for you to solve the issues. Please follow the below steps to get the problem resolved now
SyntaxError – Invalid syntax to repo INIT in the AOSP Code
Repo init failed to execute the source code.
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
Solutions
Question : SyntaxError: Invalid syntax to repo init in the AOSP code
Answer: I believe python version is the problem. Run the repo init using python3 to solve the problem.
Solution 1
Problem is, I believe python version. Run the repo init using python3 to solve the problem.
Just follow the Command Below
curl https://storage.googleapis.com/git-repo-downloads/repo-1 > ~/bin/repo
This will resolve your problem.
Solution 2
These steps will help you solve this problem.
-
Last version of repo:
curl https://storage.googleapis.com/git-repo-downloads/repo-1 > repo
- To make it executable, change right: $codeTag2
-
Your repo init can be run with python3 using the “repo” you downloaded:
python3 repo init -u [email protected]:xxx/xx_manifest.git -b xxx
Solution 3
Double-check you Python version between:
-
Your Ubuntu build machine (where
repo init
works). -
Your VM Ubuntu machine (where
repo init
fails).
You can see the same error here. It suggests that you are trying to execute python2
using a PYTHONPATH
, which is only applicable for python3
.
Solution 4
Simply modify the first line in /usr/bin/repo to make it yours.
#!/usr/bin/python
To
#!/usr/bin/python3
This instructs the system not to use the default Python but Python3.
Final Words
The above are useful solutions for the question “SyntaxError: invalid syntax to repo init in the AOSP code?”, if you can’t solve it well. Please leave a message.