问题描述
-
Win10 64位 + VMware Workstation Pro
-
平台:虚拟机安装 : ubuntu 20.04
-
RT-Thread userapps ,地址 https://github.com/RT-Thread/userapps
-
问题:使用 scons 编译 rt-smart 的 userapps 时,一直报
ModuleNotFoundError: No module named 'lib2to3'
的错误 -
具体信息如下
rtt@ubuntu:~/smart/userapps$ scons
scons: Reading SConscript files ...
ModuleNotFoundError: No module named 'lib2to3':
File "/home/rtt/smart/userapps/SConstruct", line 57:
BuildDir(os.path.join(cwd, 'apps'))
File "/home/rtt/smart/userapps/SConstruct", line 24:
BuildApplication(item, path + '/SConscript', usr_root = '.')
File "/home/rtt/smart/userapps/tools/building.py", line 511:
env = BuildEnv()
File "/home/rtt/smart/userapps/tools/building.py", line 125:
from install import TOOL_INSTALL
File "/home/rtt/smart/userapps/tools/install.py", line 143:
from lib2to3.fixes.fix_apply import FixApply
初步尝试
-
尝试清理工程,重新 git 拉取代码,发现依旧报错。
-
更换 gcc 交叉编译工具,问题依旧
-
由于这个 git 仓库在其他的电脑上是正常编译过的,所以开始怀疑 ubuntu 20.04 本身的【编译环境】有差异
解决方法
-
通过网上搜索,并尝试在 ubuntu 20.04 上安装 缺少的软件包,问题解决。
-
遇到找不到软件包时,可以尝试在 ubuntu 上安装一下软件包,让我诧异的是,ubuntu 上果然有这个
2to3
软件包
安装方法: $ sudo apt install 2to3
安装成功后,并且可以正常的使用 scons 编译了,这个 2to3
lib 之前没有遇到过
小结
- ubuntu 上 编译时,如果遇到 xxx 找不到, 可以尝试使用 apt-cache search xxx 搜索一下依赖的组件,然后使用
sudo apt install xxx
尝试安装软件包,有时候即使输入的名字不对,ubuntu 会有其他可用软件包的提示。