SavinaRoja / PyUserInput

A module for cross-platform control of the mouse and keyboard in python that is simple to install and use.
GNU General Public License v3.0
1.07k stars 244 forks source link

UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: invalid start byte #81

Open ghacosta opened 8 years ago

ghacosta commented 8 years ago

System Data: Ubuntu 14.04 Desktop KDE Python 2.7.6 python-xlib installed PyUserInput installed using pip install

I'm not being able to execute this sample test:

from pymouse import PyMouse

m = PyMouse()
x = 100
y = 250
m.position() #gets mouse current position coordinates
m.move(x,y)
m.click(x,y) #the third argument "1" represents the mouse button
m.press(x,y) #mouse button press
m.release(x,y) #mouse button release

I'm getting a UnicodeDecodeError. This is my log:

Traceback (most recent call last):                                              
  File "test.py", line 6, in <module>                                           
    m = PyMouse()                                                               
  File "/usr/local/lib/python2.7/dist-packages/pymouse/x11.py", line 86, in __init__                                                                            
    self.display = Display(display)                                             
  File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 80, in __init__ 
    self.display = _BaseDisplay(display)                                        
  File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 62, in __init__
    display.Display.__init__(*(self, ) + args, **keys)
  File "/usr/lib/python2.7/dist-packages/Xlib/protocol/display.py", line 61, in __init__
    name, host, displayno)
  File "/usr/lib/python2.7/dist-packages/Xlib/support/connect.py", line 93, in get_auth
    return getattr(mod, modname).get_auth(sock, dname, host, dno)
  File "/usr/lib/python2.7/dist-packages/Xlib/support/unix_connect.py", line 116, in new_get_auth
    au = xauth.Xauthority()
  File "/usr/lib/python2.7/dist-packages/Xlib/xauth.py", line 84, in __init__
    self.entries.append((family, addr.decode('UTF-8'),
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: invalid start byte

Anyone else had this error? Please, any help or suggestion is welcome!

Thanks in forward.

moses-palmer commented 8 years ago

What does the following command yield? Run in a terminal:

python -c "import os, Xlib.display; print(os.getenv('DISPLAY'));

print(Xlib.display.Display())"

Can you run other Python applications that use _Python Xlib_?

2016-01-22 4:10 GMT+01:00 Guille Acosta notifications@github.com:

System Data: Ubuntu 1404 Desktop KDE Python 276 python-xlib installed PyUserInput installed using pip install

I'm not being able to execute this sample test:

from pymouse import PyMouse

m = PyMouse() x = 100 y = 250 mposition() #gets mouse current position coordinates mmove(x,y) mclick(x,y) #the third argument "1" represents the mouse button mpress(x,y) #mouse button press mrelease(x,y) #mouse button release

I'm getting a UnicodeDecodeError This is my log:

Traceback (most recent call last): File "testpy", line 6, in m = PyMouse() File "/usr/local/lib/python27/dist-packages/pymouse/x11py", line 86, in init selfdisplay = Display(display) File "/usr/lib/python27/dist-packages/Xlib/displaypy", line 80, in init selfdisplay = BaseDisplay(display) File "/usr/lib/python27/dist-packages/Xlib/displaypy", line 62, in init displayDisplayinit((self, ) + args, *_keys) File "/usr/lib/python27/dist-packages/Xlib/protocol/displaypy", line 61, in init name, host, displayno) File "/usr/lib/python27/dist-packages/Xlib/support/connectpy", line 93, in get_auth return getattr(mod, modname)get_auth(sock, dname, host, dno) File "/usr/lib/python27/dist-packages/Xlib/support/unix_connectpy", line 116, in new_get_auth au = xauthXauthority() File "/usr/lib/python27/dist-packages/Xlib/xauthpy", line 84, in init selfentriesappend((family, addrdecode('UTF-8'), File "/usr/lib/python27/encodings/utf_8py", line 16, in decode return codecsutf_8_decode(input, errors, True)UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: invalid start byte

Anyone else had this error? Please, any help or suggestion is welcome!

Thanks in forward

— Reply to this email directly or view it on GitHub https://github.com/SavinaRoja/PyUserInput/issues/81.

ghacosta commented 8 years ago

Thanks for your reply!

I ran that on terminal and this was the output:

root@c288:~# python -c "import os, Xlib.display; print(os.getenv('DISPLAY'));
> print(Xlib.display.Display())"
:50
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 80, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 62, in __init__
    display.Display.__init__(*(self, ) + args, **keys)
  File "/usr/lib/python2.7/dist-packages/Xlib/protocol/display.py", line 61, in __init__
    name, host, displayno)
  File "/usr/lib/python2.7/dist-packages/Xlib/support/connect.py", line 93, in get_auth
    return getattr(mod, modname).get_auth(sock, dname, host, dno)
  File "/usr/lib/python2.7/dist-packages/Xlib/support/unix_connect.py", line 116, in new_get_auth
    au = xauth.Xauthority()
  File "/usr/lib/python2.7/dist-packages/Xlib/xauth.py", line 84, in __init__
    self.entries.append((family, addr.decode('UTF-8'),
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: invalid start byte

This give you any idea?

Regards.

ghacosta commented 8 years ago

@moses-palmer about the 2nd question, I'm not being able to install PyAutoGUI by using pip install.

The error cause that terminal shows me it's the same:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 0: invalid start byte

I can't figure out the consecuense, hope you can guide me with solution.

moses-palmer commented 8 years ago

The errors indicate that the problems that you experience are not related to PyUserInput, but rather an X misconfiguration or unexpected machine state.

The value for for the environment variable $DISPLAY seems rather high (:50, on a normal desktop system it tends to be :0).

I don't know enough about the internals of X to offer you a solution, but you may want to check the following:

I will close this issue, as it does not appear to be related to PyUserInput. Good luck in finding out the root cause!

EDIT: I don't have access to close issues. @SavinaRoja: can you please close this issue?

2016-01-22 21:32 GMT+01:00 Guille Acosta notifications@github.com:

@moses-palmer https://github.com/moses-palmer about the 2nd question, I'm not being able to install PyAutoGUI by using pip install.

The error cause that terminal shows me it's the same:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 0: invalid start byte

I can't figure out the consecuense, hope you can guide me with solution.

— Reply to this email directly or view it on GitHub https://github.com/SavinaRoja/PyUserInput/issues/81#issuecomment-174038380 .