pythonarduinoserial-port

AttributeError: module 'serial' has no attribute 'Serial'


from serial import serial
joystick = serial.Serial("COM3", 9600)
joystick_x = joystick.write('0')
if joystick_x==1023:
    print("Right")
elif joystick_x != 1023:
    print("Not right");

and I received error message:

Traceback (most recent call last):
  File "C:/Users/Mine_science/Desktop/snu6/산출물/arduino.py", line 1, in <module>
    from serial import serial
  File "C:\Users\Mine_science\AppData\Local\Programs\Python\Python35\lib\site-packages\serial\serial\__init__.py", line 13, in <module>
    from serial.serialutil import *
ImportError: No module named 'serial.serialutil'

also Can you give me some advices to get each pin.


Solution

  • Looking at the documentation it looks like you only need to do

    import serial

    instead of

    from serial import serial

    http://pyserial.readthedocs.io/en/latest/shortintro.html