0
I am trying to control Arduino by a Python script through the "pyserial" and "serial" library. But every time I run the code it misses the first few lines:
import serial
ser = serial.Serial('COM7', 9600)
error returned:
Traceback (most recent call last):
File "[...]teste.py", line 3, in <module>
ser = serial.Serial('COM7', 9600)
AttributeError: 'module' object has no attribute 'Serial'
I have already given a google search, but all applied solutions return error. Can anyone help me? Arduin is connected, I already loaded the code into it, but the problem is actually in the library.
Already deletes library folders and installed again.
I use Pycharm and Sublime
Result of print(dir(serial))
:
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'abs', 'absolute_import', 'all', 'any', 'apply', 'ascii', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'division', 'divmod', 'enumerate', 'errors', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'format', 'frozenset', 'generators', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'hooks', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'memoryview', 'meta', 'min', 'model', 'native_str', 'nested_scopes', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'print_function', 'properties', 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'request', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'standard_library', 'staticmethod', 'str', 'sum', 'super', 'sys', 'test', 'tuple', 'type', 'unichr', 'unicode', 'unicode_literals', 'utilities', 'vars', 'with_statement', 'xrange', 'zip']
What version of Python? How did you install the module pyserial? Shortly after the
import
what the result ofprint(dir(serial))
?– Woss