ImportError: cannot import name 'spawn' from 'distutils'

ImportError: cannot import name 'spawn' from 'distutils'

我正在按照 here 的说明构建 raspberry pi 内核映像和根文件系统。 每个命令输出:

1.

repo init -u https://code.rdkcentral.com/r/manifests -b rdk-next -m rdkb-extsrc.xml
...
repo has been initialized in /home/username
repo sync -j4 --no-clone-bundle
...
repo sync has finished successfully.
source meta-cmf-raspberrypi/setup-environment
...
### Shell environment set up for builds. ###

You can now run 'bitbake <target>'
$ bitbake rdk-generic-broadband-image
/home/username/openembedded-core/bitbake/lib/bb/fetch2/clearcase.py:161: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if command is 'mkview':
/home/username/openembedded-core/bitbake/lib/bb/fetch2/clearcase.py:168: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif command is 'rmview':
/home/username/openembedded-core/bitbake/lib/bb/fetch2/clearcase.py:172: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif command is 'setcs':
Traceback (most recent call last):
  File "/home/username/openembedded-core/bitbake/bin/bitbake", line 31, in <module>
    import bb
  File "/home/username/openembedded-core/bitbake/lib/bb/__init__.py", line 79, in <module>
    from bb import fetch2 as fetch
  File "/home/username/openembedded-core/bitbake/lib/bb/fetch2/__init__.py", line 1794, in <module>
    from . import clearcase
  File "/home/username/openembedded-core/bitbake/lib/bb/fetch2/clearcase.py", line 73, in <module>
    from   distutils import spawn
ImportError: cannot import name 'spawn' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)

与前 3 个不同,最后一个命令以错误结束。我知道使用

可以毫无问题地修复此错误
sudo apt-get install python3-distutils

但我不明白为什么。整个构建只能使用 Python >= 2.7 而不是 Python 3 来完成。但在这种特殊情况下,出于某种原因,它使用 Python 3 库。我的问题是:使用 Python 3 库会导致不可预见的 build\work 时间错误吗?如果是,是否可以用一些 Python 2.x 包来解决这个问题?
我尝试构建它:

    $ which python
   /usr/bin/python
    $ python -V
   Python 2.7.18

最新的 bitbake 好像是 Python 3 (header in source code) and has been for nearly 6 years! (change commit)

#!/usr/bin/env python3
#
...

我没有你的环境,但最新版本很有可能适合你(它似乎只是在构建,不是最终产品)

你可以

  • 与 Python 3
  • 一起工作
  • 查看 Python3 (2016) 之前的版本,希望它能正常工作