1

I get a nameError when using Serial. I believe that i am not importing serial properly.

from serial import *
serialPort = Serial("COM3", 9600)

i've installed pyserial through pip. Am i doing something wrong? Has anyone else experienced this error?

Gian Diaz
  • 55
  • 1
  • 6
  • Can you paste the full TraceBack here ? – ZdaR Oct 18 '17 at 07:16
  • Traceback (most recent call last): File "D:\reconremastered\serial.py", line 1, in from serial import * File "D:\reconremastered\serial.py", line 34, in serialPort = Serial("COM3", 9600) NameError: name 'Serial' is not defined – Gian Diaz Oct 18 '17 at 07:17
  • @GianDiaz Do not give your modules the same name as other modules you want to import. – Stop harming Monica Oct 18 '17 at 07:47
  • @GianDiaz you can edit your questions to include additional information, such as your traceback. Please don't add such things as comment. – mata Oct 18 '17 at 07:49
  • Okay, thank you for all the inputs. – Gian Diaz Oct 19 '17 at 08:17

1 Answers1

3

You called your file serial.py, which will shadow the installed serial module. Rename your file to something else, then it should work.

mata
  • 67,110
  • 10
  • 163
  • 162