getting the return error for the code that I am running. since this is a copied code I did not write it and am not sure how to fix it. OP WINDOWS 10 anaconda3 python 3.7.6
CODE:
#Purpose: Save data from an arduino into file using python
#Name: Kira Kemock
#Date: 7/24/2020
#filename = myfile.txt
import serial ****LINE 5*****
port_addr='COM4' # com port of the arduino
baud='9600'
file_name='mydata.txt' # this file will be saved in the same location as the py file
with serial.Serial(port_addr,baud) as port, open(file_name,"w+", 256) as outf:
for i in range(200): #read 200 lines into the file
fullline = port.readline()
line = str(fullline)
outf.write(line)
outf.write('\n')
outf.flush()
RETURN:
runfile('C:/PythonCode/SaveSerial.py', wdir='C:/PythonCode', post_mortem=True)
Traceback (most recent call last):
File "C:\PythonCode\SaveSerial.py", line 5, in <module>
import serial
ModuleNotFoundError: No module named 'serial'
LINE 5 HAS BEEN MARKED WITH LINE 5 * IN ORDER TO HELP IDENTIFY THE ISSUE
You need to install serial. you can do it with
pip3 install serial
Open powershell and type this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.