简体   繁体   English

pyserial库缺少`Serial`属性(带有python 2.7的Ubuntu 16.04)

[英]`Serial` attribute missing with the pyserial library (ubuntu 16.04 with python 2.7)

import serial 

ser = serial.Serial("/dev/ttyACM0", baudrate = 9600, timeout=1)

while 1:

    Data = ser.readline().decode('ascii')
print(Data)

Error: AttributeError: 'module' object has no attribute 'Serial' 错误:AttributeError:“模块”对象没有属性“序列”

You're importing the module, not the class. 您要导入模块,而不是类。 So, you have to use: 因此,您必须使用:

from serial import serial

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ubuntu 16.04 anaconda python 2.7上的caffe安装 - caffe installation on ubuntu 16.04 anaconda python 2.7 python 3和pyserial 2.7 - python 3 and pyserial 2.7 没有pyserial的Python序列 - Python serial without pyserial Ubuntu 16.04,Python 2.7 - ImportError:没有名为enum的模块 - Ubuntu 16.04, Python 2.7 - ImportError: No module named enum pySerial AttributeError:模块'serial'没有属性'Serial' - pySerial AttributeError: module 'serial' has no attribute 'Serial' 如何使用Python 2.7(可能还有pyserial)检查Linux中的串口是否已经打开(通过其他进程)? - How to check if serial port is already open (by another process) in Linux, using Python 2.7 (and possibly pyserial)? 如何修复TypeError:python 3.4,pyserial 2.7虚拟串口需要一个整数 - How to Fix TypeError: an integer is required in python 3.4, pyserial 2.7 virtual serial port pyserial.readline()与python 2.7 - pyserial.readline() with python 2.7 Ubuntu 16.04 将 python 从 2.7 升级到 3.6 然后再次将 2.7 设置为默认值后,终端未打开 - Ubuntu 16.04 Terminal not opening after upgarding python from 2.7 to 3.6 and then again setting 2.7 as default OpenCV-Python安装-缺少vtkRenderingOpenGL的CMake错误[Ubuntu 16.04] - OpenCV-Python installation - CMake error missing vtkRenderingOpenGL [Ubuntu 16.04]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM