adrobinoga / pyzatt

Python lib to access ZKTeco's standalone devices
MIT License
106 stars 55 forks source link

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128) #2

Closed biencuong closed 5 years ago

biencuong commented 6 years ago

Please help me with this error: root@OrangePI:/home/zk/pyzatt/tests# python3 test_realtime.py ##############################################################################

TEST OF REALTIME FUNCTIONS

##############################################################################

1.Realtime Test

Traceback (most recent call last): File "test_realtime.py", line 36, in z.read_all_user_id() File "/root/.local/lib/python3.4/site-packages/PyZatt-1.0-py3.4.egg/pyzk/zkmodules/data_user.py", line 49, in read_all_user_id UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Best regards!

adrobinoga commented 6 years ago

Hi biencuong, Two questions:

  1. What device do you have (model) ?
  2. There are valid users stored in the terminal ?
biencuong commented 6 years ago

Hi biencuong, Two questions:

  1. What device do you have (model) ?
  2. There are valid users stored in the terminal ?
  1. TC 100, Firmware Version: : Ver 6.60 Aug 10 2015
  2. There are valid users in the machine.

    With the pyzk library, I process by command: import sys sys.path.append("zk") reload(sys) sys.setdefaultencoding('utf8')

adrobinoga commented 6 years ago

Could you please explain what is the idea behind

import sys
sys.path.append("zk")
reload(sys)

I didn't understand

biencuong commented 6 years ago

Bạn có thể giải thích ý tưởng đằng sau

import sys
sys.path.append("zk")
reload(sys)

Tôi không hiểu import sys sys.path.append ("zk") reload (sys) sys.setdefaultencoding ('utf8') Since the username has a unicode character, I use that to fix the error "UnicodeDecodeError: 'ascii' codec"

adrobinoga commented 6 years ago

So you fixed the error with that? If so it is working fine or there is still a problem? with the realtime test it should appear some events on the terminal, that can be triggered by placing finger on the reader, for example

biencuong commented 6 years ago

So you fixed the error with that? If so it is working fine or there is still a problem? with the realtime test it should appear some events on the terminal, that can be triggered by placing finger on the reader, for example

It does not solve the problem (only works with python2). Now we need to solve the problem of UnicodeDecodeError: 'ascii' in data_user.py, line 49, in read_all_user_id.

adrobinoga commented 5 years ago

Im not sure, but maybe replacing 49 line in data_user.py with

# extract user name
user_name = users_dataset[i+11:i+35].decode('utf-8')

Should work, I did this in a new branch issue2-name_error

biencuong commented 5 years ago

I did it, thank you!