我试图混淆我的项目,但收到错误 ModuleNotFoundError: No module named 'pyarmor_runtime_000000',所以我尝试混淆一个仅包含 2 个文件的非常简单的文件夹,如下
test
├── __init__.py
├── test2.py
└── test.py
每个文件的内容只是一个打印语句。我用这个命令来混淆
pyarmor gen test
,
这导致了 dist 文件夹的结构
├── pyarmor_runtime_000000
│ ├── __init__.py
│ └── pyarmor_runtime.so
└── test
├── __init__.py
├── test2.py
└── test.py
然后我运行
python PATH/dist/test/test.py
但出现错误 ModuleNotFoundError: No module named 'pyarmor_runtime_000000'
我使用的是pyarmor最新版本,我的操作系统是ubuntu,python版本是3.10
可能是你的路径设置错误。
目录树应该是这样的:
test
├── dist
| └── pyarmor_runtime_000000
| ├── __init__.py
│ └── pyarmor_runtime.so
├── __init__.py
├── test2.py
└── test.py
test.py
处的路径应如下所示:
import sys
runtime_dir = './dist/'
sys.path.append(runtime_dir)
如果它不起作用,可能与 python 如何考虑项目上的 dir 路径有关。