Doubt with Pyserial on Mac

2

My problem is this, I just bought a MacBook Pro computer, I used to use Windows 10 to do Python practices, connecting it to Arduino using the Pyserial which was included in the Pycharm program. Now that I am suando Mac the program Pycharm does not recognize me the port that identifies me as arduino, in this case it is:

"/ dev / cu.usbmodem1421"

At the time of compiling, I get the following error:

"SyntaxError: Non-ASCII character '\xc2' in file 
/Users/StoomBassCow/PycharmProjects/untitled1/aperro/holamundo.py on line 4,
but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details"

Someone who can explain to me what the problem is?

My code is:

# -*- coding: utf-8 -*-

import sys

print sys.getdefaultencoding()

import serial

puertoserie = serial.Serial('/dev/cu.usbmodem1421',9600)

while True:
    tecla = input("Presiona la tecla 1 para encender el led")

    if tecla.lower() == 'e':    
        puertoserie.write(b'e')
    else:
        puertoserie.write(b'a')
    
asked by StoomBassCow 15.07.2016 в 04:17
source

1 answer

1

Since you are using the header # -*- coding: utf-8 -*- and I do not see any strange characters, I can only imagine that the failure is due to some space in another encoding. So try eliminating all the spaces, especially those of the line that you mention in the error, also re-devise it but using only blank spaces instead of tabs.

    
answered by 15.07.2016 в 06:17