使用patch修补python中serial.tools中的一个Bug
来源:互联网 发布:安利网络直销模式 编辑:程序博客网 时间:2024/04/27 08:15
今天在写python的时候遇到了一个错误:
port_list = list(serial.tools.list_ports.comports())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/serial/tools/list_ports_posix.py", line 122, in comports
return [(d, describe(d), hwinfo(d)) for d in devices]
File "/usr/lib/python2.7/dist-packages/serial/tools/list_ports_posix.py", line 93, in describe
return usb_lsusb_string(sys_usb)
File "/usr/lib/python2.7/dist-packages/serial/tools/list_ports_posix.py", line 80, in usb_lsusb_string
return base
NameError: global name 'base' is not defined
像往常一样,把错误原因复制下来,在google上搜索,看看还有哪个倒霉蛋和我一样,结果是肯定的,是有这样的倒霉蛋。
经过查找,发现是python的serial.tools中的一个Bug,不是我的代码的问题,心中顿时。。。
遇到问题就解决呗,先看看其他倒霉蛋怎么解决的:http://sourceforge.net/p/pyserial/patches/26/。
呃呃呃,好吧,上面的楼主把问题贴出来,二楼给了一个.diff文件,三楼就一个Thanks结束了。。。这不是欺负我等英语渣渣的初级程序猿呢?
没办法,问题还是要解决的。首先把什么是diff文件google了一下,奥,原来是一个补丁文件,怎么用呢?用patch工具。那patch工具又怎么用呢?
首先,先切换到要打补丁的那个文件下,然后patch list_ports_posix.py (补丁文件的目录),当然,保险起见,首先备份一下。之后把原来的.pyc给删掉。
再次进入到python命令行中,一开始的代码可以用了。。。
over
(By the way,我只是为了解决问题,所以许多细节我没有深入了解,有时间我再深入了解)- 使用patch修补python中serial.tools中的一个Bug
- python中patch的使用
- 可能是python 2.3中的一个bug
- svg.js使用中的一个bug
- 一个在 Returns Form 里面找不到 serial number 的bug
- diff命令修补命令patch详解
- python mock patch 的使用
- python--serial
- python--serial
- Python---serial
- git 在patch中的使用
- Cg中的一个Bug
- IE7中的一个bug
- ipconntrack中的一个BUG
- 违例中的一个BUG
- NALDecoder中的一个bug
- 【Python】Windows中Python Serial获取PC下串口名称
- ARM GNU 工具链在使用gprof中的一个bug
- PageRank算法简介
- 如何成为游戏主程
- C#中的格式化输出
- php安装不了 sqlserver 解决办法 mssql.dll php_sqlsvr_55_ts.dll
- 闹钟倒计时动画效果实现。仿聚美优品H5闪购动画。
- 使用patch修补python中serial.tools中的一个Bug
- NSNumber的大小比较
- LINK : fatal error LNK1158: cannot run 'rc.exe'
- Android屏幕适配全攻略
- Storyboard 全解析 (一)
- 制作触摸屏网页程序1
- cocos2d-x VS2012 UTF8码导致的错误的解决办法
- 使用Volley框架,不走onResponse和onError方法
- 编写一个智能指针类