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

19,990

Solution 1

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

Solution 2

I installed serial library using "pip3 install serial" and get the same error even calling the library using "import serial". Then I found that if first UNINSTALL serial:

pip3 uninstall serial

and then install pyserial:

pip3 install pyserial

fixed the problem for python 3.

Solution 3

uninstalling python and pyserial package completely and then

installing python(python 3 in my case) back -

for all users and add Paths correctly

and then use

pip3 for installing pyserial

fixed all my issues

Solution 4

I was getting the same error, but what works for me was:

  1. uninstall serial : pip3 uninstall serial
  2. uninstall pyserial: pip3 uninstall pyserial
  3. reinstall a previous version of pyserial: pip3 install pyserial==3.3 (I had 3.5 version)
Share:
19,990
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years
    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.

  • Admin
    Admin over 7 years
    I solved problem. Actually, I didn't download the library inside the Python:P
  • Luis Jose
    Luis Jose about 4 years
    After installing the serial library using pip3, I get the same answer even though I'm using Import serial to call it.