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

Pyarmor混淆后运行报错ModuleNotFoundError: No module named 'pyarmor_runtime_000000'

解决Pyarmor混淆后ModuleNotFoundError: No module named 'pyarmor_runtime_000000'问题

问题根源

Pyarmor生成的pyarmor_runtime_000000模块位于dist根目录,但直接运行dist/test/test.py时,Python的模块搜索路径(sys.path)默认只包含当前脚本所在目录(dist/test)和系统标准路径,无法找到上级目录的runtime模块。

可行解决方案

方案1:运行时指定Python模块搜索路径

执行脚本时,通过PYTHONPATH环境变量将dist目录加入搜索路径:

PYTHONPATH=PATH/dist python PATH/dist/test/test.py

替换PATH为你的实际路径,这样Python就能识别dist根目录下的runtime模块。

方案2:混淆时指定runtime模块的相对路径

使用Pyarmor的--runtime-path参数,让混淆后的代码自动定位runtime模块的位置。执行混淆命令时添加该参数:

pyarmor gen --runtime-path ../pyarmor_runtime_000000 test

生成的混淆代码会从test目录的上级目录(即dist根目录)加载runtime模块,之后直接运行python PATH/dist/test/test.py即可。

方案3:手动调整runtime模块位置

把dist/pyarmor_runtime_000000整个目录复制到dist/test目录下,调整后的结构为:

dist/test
├── __init__.py
├── test2.py
├── test.py
└── pyarmor_runtime_000000
    ├── __init__.py
    └── pyarmor_runtime.so

之后运行python PATH/dist/test/test.py,Python就能在当前目录找到所需的runtime模块。

额外检查点

  • 确认pyarmor_runtime_000000目录下的__init__.py和pyarmor_runtime.so文件完整无损坏。
  • 验证Ubuntu系统下的Python 3.10能正常加载.so格式的runtime库(确保Pyarmor生成的库与系统架构匹配)。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 05:33:26