最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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!!!

发布评论

评论列表(0)

  1. 暂无评论