UnicodeEncodeError: 'gbk' codec can't encode character '\u0158' in position 2: illegal multibyte sequence

Windows 7,Python 3.7.9(64bit),I was trying install frida manually follow a blog,then I executed command “python setup.py installI” in frida-tools-1.1.0 directory.,the cmd showed below:Installing frida-script.py script to D:\Software\Python\Python37\DLLs\Scripts Traceback (most recent call last): File "setup.py", line 53, in <module> "frida-trace = frida_tools.tracer:main" File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\__init__.p y", line 144, in setup return distutils.core.setup(**attrs) File "D:\Software\Python\Python37\Lib\distutils\core.py", line 148, in setup dist.run_commands() File "D:\Software\Python\Python37\Lib\distutils\dist.py", line 966, in run_com mands self.run_command(cmd) File "D:\Software\Python\Python37\Lib\distutils\dist.py", line 985, in run_com mand cmd_obj.run() File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\in stall.py", line 67, in run self.do_egg_install() File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\in stall.py", line 117, in do_egg_install cmd.run(show_deprecation=False) File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\ea sy_install.py", line 424, in run self.easy_install(spec, not self.no_deps) File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\ea sy_install.py", line 673, in easy_install return self.install_item(None, spec, tmpdir, deps, True) File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\ea sy_install.py", line 720, in install_item self.process_distribution(spec, dist, deps) File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\ea sy_install.py", line 745, in process_distribution self.install_egg_scripts(dist) File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\ea sy_install.py", line 621, in install_egg_scripts self.install_wrapper_scripts(dist) File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\ea sy_install.py", line 814, in install_wrapper_scripts self.write_script(*args) File "D:\Software\Python\Python37\DLLs\lib\site-packages\setuptools\command\ea sy_install.py", line 858, in write_script f.write(contents) UnicodeEncodeError: 'gbk' codec can't encode character '\u0158' in position 2: i llegal multibyte sequence
It seems wrong with easy_install.py,below is the code

        mask = current_umask()
        if os.path.exists(target):
        with open(target, "w" + mode) as f:
        chmod(target, 0o777 - mask)

line 858 is:f.write(contents)
two days age,I met this error first,and I modify line 857,it becomes with open(target,"w",encoding='utf-8') as f:' then I modify line 858,it becomes f.write(str(contents))` with the help of GPT,then it worked,but I
don’t know whether it is the solution to solve it.Thanks.

In order to preserve formatting, please select any code or traceback that you post and then click the </> button.

These days it’s recommended to use pip, and on Windows it’s recommended that you use the Python Launcher py:

py -m pip install frida-tools

Thanks for applying,it worked fine and Create a file called frida-script.py,no frida.exe,is it normal?


The “frida-tools” package is described as “Frida CLI tools”.

There’s also:

py -m pip install frida

The “frida” package is described as “Python bindings for Frida”.

The '\u0158' character is Ř. It comes from Czech language, so you can’t write it with GBK. The code tried to use your platform encoding to write some files.

Instead of trying to edit Setuptools, you can set the PYTHONIOENCODING environment variable to make UTF-8 the default.

I don’t know what file was written, or what will use it later. Of course, when it’s used, that tool has to understand UTF-8, too.

Just to make sure: it should be possible to update Setuptools as far as 68.0.0.

Please also see the previous thread. The overall problem is fairly complicated.

Thanks.I solved the problem by the answer of [Matthew Barnett],it seems was ignored by online install,

some wrong with me about frida,I execute py -m pip install frida and worked.

D:\Software\fr>py -m pip install frida
Requirement already satisfied: frida in d:\software\python\python37\dlls\lib\sit
e-packages\frida-12.1.0-py3.7-win-amd64.egg (12.1.0)

I couldn’t execut cmd frida-ps -U because no frida.exe file.When I execute python code in cmd ,python code is below:

import frida
device = frida.get_usb_device()
processes = device.enumerate_processes()
for process in processes:
    print("PID: {}, Name: {}".format(process.pid, process.name))

and cmd shows below:

Traceback (most recent call last):
  File "12.txt", line 7, in <module>
    processes = device.enumerate_processes()
  File "D:\Software\Python\Python37\DLLs\lib\site-packages\frida-12.1.0-py3.7-wi
n-amd64.egg\frida\core.py", line 65, in enumerate_processes
frida.ServerNotRunningError: unable to connect to remote frida-server: Error sen
ding data: 您的主机中的软件中止了一个已建立的连接。

I try to solve it by two cmd below:

adb forward tcp:27042 tcp:27042
adb forward tcp:27043 tcp:27043

but it didn’t work.Do you hava any suggestion?