python 3 和 python 2 都无法在带有 repo 的 ubuntu 18.04 上正常运行?

python 3 和 python 2 都无法在带有 repo 的 ubuntu 18.04 上正常运行?

我在 ubuntu 18.04 上并且正在尝试初始化这个 repo:

# repo init -u https://github.com/anbox/platform_manifests.git -b anbox

因为我正在使用这个版本的python:

# python
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux

它不起作用。它说:

warning: Python 3 support is currently experimental. YMMV.
Please use Python 2.6 - 2.7 instead.
Traceback (most recent call last):
  File "/usr/bin/repo", line 886, in <module>
    main(sys.argv[1:])
  File "/usr/bin/repo", line 854, in main
    _Init(args, gitc_init=(cmd == 'gitc-init'))
  File "/usr/bin/repo", line 340, in _Init
    _CheckGitVersion()
  File "/usr/bin/repo", line 394, in _CheckGitVersion
    ver_act = ParseGitVersion(ver_str)
  File "/usr/bin/repo", line 364, in ParseGitVersion
    if not ver_str.startswith('git version '):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

好的。我创建了一个指向 Python 2.7 的符号链接:

# ln -s /usr/bin/python2.7 /usr/bin/python
root@ziomario-Z390-AORUS-PRO:/home/ziomario/Scrivania/Data/Nano/I9/anbox-work# python
Python 2.7.17 (default, Feb 27 2021, 15:10:58) 
[GCC 7.5.0] on linux2

但即使这次它也不起作用:

# repo init -u https://github.com/anbox/platform_manifests.git -b anbox
Get https://gerrit.googlesource.com/git-repo/clone.bundle
Get https://gerrit.googlesource.com/git-repo
remote: Counting objects: 8, done
remote: Finding sources: 100% (142/142)
remote: Total 142 (delta 64), reused 142 (delta 64)
Ricezione degli oggetti: 100% (142/142), 137.91 KiB | 4.18 MiB/s, done.
Risoluzione dei delta: 100% (64/64), completed with 14 local objects.
Da https://gerrit.googlesource.com/git-repo
   ceba2dd..323b113  main       -> origin/main
   b64bec6..511a0e5  stable     -> origin/stable
 * [nuova tag]       v2.13      -> v2.13
 * [nuova tag]       v2.13.1    -> v2.13.1
 * [nuova tag]       v2.13.2    -> v2.13.2
 * [nuova tag]       v2.13.3    -> v2.13.3
 * [nuova tag]       v2.13.4    -> v2.13.4
 * [nuova tag]       v2.13.5    -> v2.13.5
 * [nuova tag]       v2.13.6    -> v2.13.6
 * [nuova tag]       v2.13.7    -> v2.13.7
  File "/home/ziomario/Scrivania/Data/Nano/I9/anbox-work/.repo/repo/main.py", line 79
    file=sys.stderr)
        ^
SyntaxError: invalid syntax

我还能做什么?

答案1

在 python2 下运行命令后,将有一个可用的 repo 脚本更新,能够处理 python3。它的位置是.repo/repo/repo,相对于您执行命令的目录。将您的 python 版本更改回 python3,然后在该文件夹中运行:

.repo/repo/repo -u https://github.com/anbox/platform_manifests.git -b anbox

如果未设置,请首先设置您的 git 名称和电子邮件,否则您会遇到新的错误。

相关内容