Python Forum

Full Version: Module not found question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
New to python,I'm used to Matlab and Arduino. I have 3.10.6 python,and just downloaded current version of spyder.
All I'm trying to do is read serial data printed from Arduino analog pin, using serial in spyder and plot.Simple......so I thought.

Spyder code:

import serial

ser = serial.Serial("COM3", 115200)
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
fig=plt.figure()


i=0
x=list()
y=list()
i=0

ser.close()
ser.open()
while True:

    data = ser.readline()
    print(data.decode())
    x.append(i)
    y.append(data.decode())

    plt.scatter(i, float(data.decode()))
    i += 1
    plt.show()
    plt.pause(0.0001)  # Note this correction
Spyder Error:

Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.34.0 -- An enhanced Interactive Python.

runfile('C:/Users/Mich/.spyder-py3/temp.py', wdir='C:/Users/Mich/.spyder-py3')
Traceback (most recent call last):

  File "C:\Users\Mich\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\users\mich\.spyder-py3\temp.py", line 3, in <module>
    import serial

ModuleNotFoundError: No module named 'serial'
Not having the best time with python currently,could someone point me in right direction.I've tried going through and trying: https://packaging.python.org/en/latest/t...ages/#id18

but cmd says pip isn't recognized...even though I have,using tutorial above.


nvm, found solution had to use anaconda 3,install and then change spyder reference....super clear and easy,thanks for help.