如何解决导入错误:无法从“distutils”导入名称“spawn”
我正在按照 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 库会导致无法预见的构建\工作时间错误吗?如果是,是否可以使用一些 Python 2.x 包来解决这个问题?
我尝试使用以下方法构建它:
$ which python
/usr/bin/python
$ python -V
Python 2.7.18
解决方法
看起来最新的 bitbake 是 Python 3 (header in source code) 并且已经用于 nearly 6 years! (change commit)
#!/usr/bin/env python3
#
...
我没有你的环境,但最新版本很有可能适合你(它似乎只是在做一个构建而不是最终产品)
你可以
- 使用 Python 3
- 查看 Python3 (2016) 之前的版本,希望它能正常工作
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。