I'm trying out an example on Arduino: http://playground.arduino.cc/Interfacing/Python
The example (running on Ubuntu) works great in the shell:
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
while True:
print(ser.readline())
However attempting to execute as a script:
Desktop/python_arduino/./serial.py...
Which executes this:
#!/usr/bin/env python
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
while True:
print(ser.readline())
And I get this:
Traceback (most recent call last):
File "Desktop/python_arduino/./serial.py", line 2, in <module>
import serial
File "/home/leo/Desktop/python_arduino/serial.py", line 4, in <module>
ser = serial.Serial('/dev/ttyACM0', 9600)
AttributeError: 'module' object has no attribute 'Serial'
What is causing this inconsistency? It should be easy to import serial regardless of shell or script right?