I'm trying to control the arduino by a Python script through the "pyserial" and "serial" library. But every time I run the code it gives an error in 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've done a google search, but all the solutions applied return error. Can someone help me? The arduino is connected, I already loaded the code on it, but the problem is actually in the library.
I already deleted the folders from the libraries and installed them 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']