0

我正在尝试使用来自 Qualcomm 的材料在 Ubuntu 20 下为 DragonBoard 410c 构建我自己的 Android 版本。我已经从 Qualcomm 开发人员门户网站下载了文件,linux_android_board_support_package_vla.br_.1.2.7-01010-8x16.0-4.zip其中包含我解压缩到文件夹中的材料,~/Documents/linux_android_board_support_package_vla.br.1.2.7-01010-8x16.0-4使材料可用包括外壳脚本DB410c_build.sh

解包和设置是通过DB410c_build.sh执行各种操作来完成的,例如.repo使用 shell 脚本使用的 python 文件生成目录树并下载源代码。

我从各种 python 脚本中遇到了许多语法错误,看来这是为 python 2 编写的,到目前为止我已经能够解决。顺便说一句,python --version报告python 2.7.18但我仍然看到表明正在使用 python 3 的错误。

最新的错误来自python脚本,.repo/repo/subcmds/smartsync.py当它执行时,我得到以下错误,我一直无法弄清楚或通过搜索找到解决方案。

Traceback (most recent call last):
  File "/home/rick/Documents/linux_android_board_support_package_vla.br.1.2.7-01010-8x16.0-4/APQ8016_410C_LA.BR.1.2.7-01010-8x16.0_6.0.1_Marsh_Mallo_P2/.repo/repo/main.py", line 42, in <module>
    from subcmds import all as all_commands
  File "/home/rick/Documents/linux_android_board_support_package_vla.br.1.2.7-01010-8x16.0-4/APQ8016_410C_LA.BR.1.2.7-01010-8x16.0_6.0.1_Marsh_Mallo_P2/.repo/repo/subcmds/__init__.py", line 33, in <module>
    mod = __import__(__name__,
  File "/home/rick/Documents/linux_android_board_support_package_vla.br.1.2.7-01010-8x16.0-4/APQ8016_410C_LA.BR.1.2.7-01010-8x16.0_6.0.1_Marsh_Mallo_P2/.repo/repo/subcmds/smartsync.py", line 16, in <module>
    from sync import Sync
ModuleNotFoundError: No module named 'sync'

完整的python源文件,smartsync.py如下:

#
# Copyright (C) 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from sync import Sync

class Smartsync(Sync):
  common = True
  helpSummary = "Update working tree to the latest known good revision"
  helpUsage = """
%prog [<project>...]
"""
  helpDescription = """
The '%prog' command is a shortcut for sync -s.
"""

  def _Options(self, p):
    Sync._Options(self, p, show_smart=False)

  def Execute(self, opt, args):
    opt.smart_sync = True
    Sync.Execute(self, opt, args)

这只是从https://developer.qualcomm.com/hardware/dragonboard-410c/software下载的该文件中的 python 脚本的最新问题,试图使用

Android Board Support Package 
vLA.BR.1.2.7-01010-8x16.0-4

以前的大多数错误都是由于语法不正确,以及except一些很容易找到解决方案的错误(谢谢 StackOverFlow!)。raiseprintimport

但是我找不到关于这个的任何信息。

4

1 回答 1

0

问题是由于文件smartsync.py夹中的文件.repo/repo/subcmds和该文件中的from sync import Sync语句存在语法错误。

sync实际上是引用sync.py也位于文件夹中的文件,而不是该.repo/repo/subcmdspython 源代码主体外部的一些 python 文件。

from语句缺少subcmds文件所在位置的目录说明符sync.pyfrom subcmds.sync import Sync为了Sync从文件sync.py夹中的文件导入类,应该已经编写了这行代码subcmds。我认为这是因为 python 脚本正在运行,当前目录设置为.repo/repo而不是.repo/repo/subcmds.

对文件进行此更改后,脚本成功运行,直到另一个文件中出现下一个需要更正的错误。

于 2020-12-04T04:26:41.600 回答