Windows环境下编译webots的官方说明在 https://github.com/cyberbotics/webots/wiki/Windows-installation/ ,概括起来就是:先安装MYSYS2,然后git clone --recurse-submodules -j8 https://github.com/cyberbotics/webots.git ,最后make -j16 (j后面的数字的上限取决于你的CPU的线程数),在make时遇到下面报错:
- generating resources/proto-list.xml from PROTO files with prefix "webots://"
- Traceback (most recent call last):
- File "E:/msys64/home/AAA/webots/scripts/packaging/generate_proto_list.py", line 241, in
- generate_proto_list(tag)
- File "E:/msys64/home/AAA/webots/scripts/packaging/generate_proto_list.py", line 143, in generate_proto_list
- info = ProtoInfo(str(asset), asset.stem)
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- File "E:/msys64/home/AAA/webots/scripts/packaging/generate_proto_list.py", line 48, in __init__
- self.contents = file.read()
- ^^^^^^^^^^^
- UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 547: illegal multibyte sequence
- make: *** [Makefile:128: webots_dependencies] Error 1
- make: *** Waiting for unfinished jobs....
解决方案是打开报错中提到的那个py文件(就是E:/msys64/home/AAA/webots/scripts/packaging/generate_proto_list.py),找到下面这一行(这一行就是在报错中提到的第48行self.contents = file.read()的上一行):
with open(self.path, 'r') as file:
把这一行改成
with open(self.path, 'r',encoding='utf-8') as file:
即可。