本文主要是介绍ROS noetic view_frames TypeError: cannot use a string pattern on a bytes-like object,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
ROS noetic + Ubuntu20.04报错:
mc@ubun:~$ rosrun tf view_frames
Listening to /tf for 5.0 seconds
Done Listening
b'dot - graphviz version 2.43.0 (0)\n'
Traceback (most recent call last):File "/opt/ros/noetic/lib/tf/view_frames", line 119, in <module>generate(dot_graph)File "/opt/ros/noetic/lib/tf/view_frames", line 89, in generatem = r.search(vstr)
TypeError: cannot use a string pattern on a bytes-like object
查了一下,search函数需要输入str类型数据,而vstr(有可能?)不是str类型,所以需要把
m = r.search(vstr)
改成,
m = r.search(str(vstr))
如下,
try:vstr = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1]except OSError as ex:print("Warning: Could not execute `dot -V`. Is graphviz installed?")sys.exit(-1)v = distutils.version.StrictVersion('2.16')r = re.compile(".*version (\d+\.?\d*)")print(vstr)m = r.search(str(vstr))
不过同样官方的说法如下,
将
m = r.search(vstr)
改为,
m=r.search(vstr.decode('utf-8'))
我试了一下,两种都能给出正确的结果。
这篇关于ROS noetic view_frames TypeError: cannot use a string pattern on a bytes-like object的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!