You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu16.04下Python3.5运行Frida15.2.2报SyntaxError的解决方法

解决Frida15.2.2在Python3.5.2下运行的SyntaxError问题

问题描述

Ubuntu16.04系统,未更新;已安装Python2.7(默认版本)和Python3.5.2;通过pip将Frida15.2.2及frida-tools安装到Python3.5环境后,运行frida命令出现以下语法错误:

Traceback (most recent call last):
  File "/home/dilawer/.local/bin/frida", line 8, in <module>
    sys.exit(main())
  File "/home/dilawer/.local/lib/python3.5/site-packages/frida_tools/repl.py", line 38, in main
    from frida_tools.cli_formatting import format_compiling, format_compiled, format_diagnostic
  File "/home/dilawer/.local/lib/python3.5/site-packages/frida_tools/cli_formatting.py", line 24
    return f"{STYLE_RESET_ALL}Compiling {STYLE_FILE}{name}{STYLE_RESET_ALL}..."
                                                                              ^
SyntaxError: invalid syntax

原因分析

报错行使用的f"{xxx}"是f-string字符串格式化语法,该特性仅在Python3.6及以上版本支持,而当前使用的Python3.5.2不兼容此语法。这说明安装的Frida15.2.2和对应frida-tools版本已不再支持Python3.5。

解决方法

1. 卸载不兼容版本

执行以下命令卸载当前的Frida和frida-tools:

pip3 uninstall -y frida frida-tools

2. 安装兼容Python3.5的版本组合

Frida 14.x及以下版本仍支持Python3.5,搭配对应的frida-tools版本即可。例如安装Frida 14.2.18和frida-tools 9.2.5:

pip3 install frida==14.2.18 frida-tools==9.2.5

3. 确保使用Python3环境运行

由于系统默认Python版本为2.7,运行Frida时需明确指定Python3:

  • 直接通过Python3模块方式运行:
    python3 -m frida
    
  • 或者修改frida命令的shebang行:
    编辑/home/dilawer/.local/bin/frida文件,将第一行的#!/usr/bin/env python改为#!/usr/bin/env python3,之后即可直接使用frida命令。

内容的提问来源于stack exchange,提问作者Dilawer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 10:03:37