python - AttributeError: module 'serial' has no attribute 'Serial' in Pycharm - Stack Overflow

I am learning Python and need to monitor a serial port.i am using Pycharm with the following code.imp

I am learning Python and need to monitor a serial port.
i am using Pycharm with the following code.

import serial
ser = serial.Serial('com6', 9600)
while True:
    s = ser.read(10000)
    print(s)

This gives the error: AttributeError: module 'serial' has no attribute 'Serial'

PS. I have installed "serial" in pycharms python interpreter

Not sure what is wrong...

I am learning Python and need to monitor a serial port.
i am using Pycharm with the following code.

import serial
ser = serial.Serial('com6', 9600)
while True:
    s = ser.read(10000)
    print(s)

This gives the error: AttributeError: module 'serial' has no attribute 'Serial'

PS. I have installed "serial" in pycharms python interpreter

Not sure what is wrong...

Share Improve this question asked Nov 16, 2024 at 14:36 Fred_was_hereFred_was_here 12 bronze badges 1
  • 2 do you have a file called serial.py anywhere in the same folder ? – Ahmed AEK Commented Nov 16, 2024 at 14:38
Add a comment  | 

1 Answer 1

Reset to default 0

I found the solution.

So, in PyCharm you need to install pyserial not serial, even though in code you call it as as serial! Of course!!!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745656440a4638570.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信