ImportError:无法从“distutils”导入名称“spawn”

2024-09-28 05:27:38 发布

您现在位置:Python中文网/ 问答频道 /正文

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

一,

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。但在这种特殊情况下,出于某种原因,它使用Python3库。我的问题是:使用Python3库会导致不可预见的构建\工作时错误吗?如果是的话,是否可以用一些Python2.x包来解决这个问题
我尝试用以下方法构建它:

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

Tags: inpycoreimporthomeinitislib
1条回答
网友
1楼 · 发布于 2024-09-28 05:27:38

看起来最新的bitbake是Python3(header in source code),已经发布了nearly 6 years! (change commit)

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

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

你也可以

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

相关问题 更多 >

    热门问题