Python使用模块Pyserial模块报<ImportError:No module named tools.list_ports>
2015-10-01 02:53
916 查看
用pip安装pyserial后:sudo -H pip install pyserial,运行新建的程序,名称为serial.py,程序中用到:import serial.toos.list_ports,但总是提示ImportError:No module named tools.list_ports,在度娘一顿乱搜后,在stack overflow<http://stackoverflow.com/questions/14108428/pyserial-no-module-named-tools>看到有人问这个问题,一个个回答看过来,当看到:
I got here because I had the same problem. The strange thing was that
worked, but
didn't.
Turns out stupid me named the script "serial.py". After renaming it everything worked.
当时是五味杂陈,一时犯贱工程命名也是serial.py,当再重新命名为MySerial.py后,python MySerial.py编译时:
File "MySerial.py", line 15, in <module>
import serial
File "/User/zhang/Desktop/python/serial_uart/serial.py", line 18, in <module>
ImportError: No module named tools.list_ports
此时已经没有serial.py文件了,怎么报的错误还和serial.py扯上关系,最后发现该文件夹下生成了一个serial.pyc的文件,删除之后运行正常,都是名字惹的祸。
I got here because I had the same problem. The strange thing was that
import serial
worked, but
from serial.tools import list_ports
didn't.
Turns out stupid me named the script "serial.py". After renaming it everything worked.
当时是五味杂陈,一时犯贱工程命名也是serial.py,当再重新命名为MySerial.py后,python MySerial.py编译时:
File "MySerial.py", line 15, in <module>
import serial
File "/User/zhang/Desktop/python/serial_uart/serial.py", line 18, in <module>
ImportError: No module named tools.list_ports
此时已经没有serial.py文件了,怎么报的错误还和serial.py扯上关系,最后发现该文件夹下生成了一个serial.pyc的文件,删除之后运行正常,都是名字惹的祸。
相关文章推荐
- Python学习笔记<list和tuple>
- Python学习笔记<list和tuple>
- [pythontip]最大非连续子序列
- python捕获多个Exception携带msg
- Python中的除法
- Python核心编程笔记 - 第12章 模块
- 用python编写统计fasta格式的序列的长度脚本
- Scikit Learn: 在python中机器学习
- [LeetCode]题解(python):020-Valid Parentheses
- 用python统计scaffold的N50等信息
- Python3 的json 和 PHP的json
- python的list的拷贝
- 关于python的学习
- python实现读取命令行参数
- Ubuntu 下一个 vim 建立python 周围环境 构造
- python派QQ邮件
- python unittest基本介绍
- 我的Python学习收藏夹
- 汉诺塔问题,Python
- 初尝python之环境配置