2

I get this traceback when attempting to connect to a serial port on ubuntu 16.04

File "debugRead2.py", line 6, in <module>
ser = serial.Serial('/dev/ttyACM0', 115200)
AttributeError: module 'serial' has no attribute 'Serial'

My file is named debugRead2.py so it isn't an issue with naming.

When I change:

import serial
ser = serial.Serial('/dev/ttyACM0', 115200)

to

from serial import serial
ser = serial.Serial('/dev/ttyACM0', 115200)

I get:

Traceback (most recent call last):
  File "debugRead2.py", line 1, in <module>
    from serial import serial
ImportError: cannot import name 'serial'

I have both the serial and pyserial packages installed.

15
  • did you install using pip ? Commented Nov 20, 2017 at 3:31
  • yes i used pip to install Commented Nov 20, 2017 at 3:32
  • Try uninstalling the serial package. That one is for serializing JSON/YAML/XML, not using serial ports. It might be causing a conflict. Commented Nov 20, 2017 at 3:33
  • 1
    Open the Python interpreter from the same folder your code is in and type import serial; serial! What's the output? Commented Nov 20, 2017 at 3:34
  • just did, am still getting the same error Commented Nov 20, 2017 at 3:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.