【问题标题】:ImportError: cannot import name 'spawn' from 'distutils'ImportError:无法从“distutils”导入名称“spawn”
【发布时间】:2021-07-03 12:21:01
【问题描述】:

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

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 库会导致无法预料的构建\工作时间错误吗?如果是的话,是否可以使用一些 Python 2.x 包来解决这个问题?
我尝试使用以下方式构建它:

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

【问题讨论】:

    标签: python raspberry-pi bitbake


    【解决方案1】:

    看起来最新的 bitbake 是 Python 3 (header in source code) 并且一直是 nearly 6 years! (change commit)

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

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

    你可以

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

    【讨论】:

      猜你喜欢
      • 2020-12-28
      • 1970-01-01
      • 2022-10-19
      • 2022-01-22
      • 2021-06-30
      • 2020-10-19
      • 2018-08-13
      • 2015-01-26
      • 2020-10-10
      相关资源
      最近更新 更多