小编Ori*_*lyo的帖子

“ImportError: No module named serial” - 安装 pyserial 后

我正在用 python 编写一个项目,该项目最终应该在 LinkIt One IoT 设备上运行。

我已经编写了一些测试代码来检查我是否能够在 Arduino IDE 和 python 之间进行连接(我正在使用 Pycharm)。

测试代码是:

import serial
import time

arduino = serial.Serial('COM1', 115200, timeout=.1)

time.sleep(1) #give the connection a second to settle

arduino.write("Hello from Python!")

while True:
    data = arduino.readline()
    if data:
        print data.rstrip('\n')
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,我得到:

C:\Users\????\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/????/PycharmProjects/untitled2/test.py

回溯(最近一次调用最后一次):文件“C:/Users/????/PycharmProjects/untitled2/test.py”,第 1 行,在导入序列中导入错误:没有名为序列的模块

python windows

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1

windows ×1