Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: invalid syntax to repo init in the AOSP code

I have tried to repo init the source code Ubuntu build machine and it is successfully able to clone the code.

repo init -u [email protected]:xxx/xx_manifest.git -b xxx

Now I am trying repo init the source code in VM Ubuntu machine.

In between getting the error like below:

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

python version is same in build machine and vm machine 2.7.17.

like image 346
GNK Avatar asked Dec 08 '20 06:12

GNK


5 Answers

try these commands

curl https://storage.googleapis.com/git-repo-downloads/repo-1 > ~/bin/repo
chmod a+x ~/bin/repo
python3 ~/bin/repo init -u git@....
like image 64
skrrt Avatar answered Nov 19 '22 12:11

skrrt


I just had the same issue and this resolved it for me :

  • 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
like image 40
nox Avatar answered Nov 19 '22 13:11

nox


I have experienced the same issue on Ubuntu 18.04 during the installation of the OpenSTLinux Yocto layer with the following command:

repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/openstlinux-5.4-dunfell-mp1-20-11-12

Returns:

Get https://gerrit.googlesource.com/git-repo/clone.bundle
Get https://gerrit.googlesource.com/git-repo
remote: Counting objects: 2, done
remote: Finding sources: 100% (117/117)
remote: Total 117 (delta 63), reused 117 (delta 63)
Receiving objects: 100% (117/117), 142.25 KiB | 11.85 MiB/s, done.
Resolving deltas: 100% (63/63), completed with 32 local objects.
From https://gerrit.googlesource.com/git-repo
   1469c28..0588f3d  main       -> origin/main
 * [new tag]         v2.11      -> v2.11
 * [new tag]         v2.11.1    -> v2.11.1
Traceback (most recent call last):
  File "/home/xxx/Distribution-Package/openstlinux-5.4-dunfell-mp1-20-11-12/.repo/repo/main.py", line 56, in <module>
    from subcmds.version import Version
  File "/home/xxx/Distribution-Package/openstlinux-5.4-dunfell-mp1-20-11-12/.repo/repo/subcmds/__init__.py", line 38, in <module>
    ['%s' % name])
  File "/home/xxx/Distribution-Package/openstlinux-5.4-dunfell-mp1-20-11-12/.repo/repo/subcmds/upload.py", line 27, in <module>
    from hooks import RepoHook
  File "/home/xxx/Distribution-Package/openstlinux-5.4-dunfell-mp1-20-11-12/.repo/repo/hooks.py", line 472
    file=sys.stderr)

This issue goes away with using Python3 instead of Python (2.7). You can do this:

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python
like image 11
Mickael T Avatar answered Nov 19 '22 12:11

Mickael T


Try below command to make it will work 100%, tried & suggested

mkdir -p ~/.bin
PATH="${HOME}/.bin:${PATH}"
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+rx ~/.bin/repo
like image 9
Muralidhar BN Avatar answered Nov 19 '22 12:11

Muralidhar BN


One solution is to modify the first line of /usr/bin/repo and change it from

#!/usr/bin/python

to

#!/usr/bin/python3

This asks the system to use Python3 instead of the default Python.

like image 7
Nguyễn Minh Vũ Avatar answered Nov 19 '22 11:11

Nguyễn Minh Vũ