{"id":4701,"library":"pyarmor","title":"Pyarmor","description":"Pyarmor is a command-line tool designed for obfuscating Python scripts, binding them to specific machines, and setting expiration dates. It focuses on protecting intellectual property by making Python source code difficult to reverse engineer while maintaining functionality. The library is actively maintained with frequent updates and new features, with its current version being 9.2.4.","status":"active","version":"9.2.4","language":"en","source_language":"en","source_url":"https://github.com/dashingsoft/pyarmor","tags":["security","obfuscation","cli","licensing","intellectual-property","code-protection"],"install":[{"cmd":"pip install pyarmor","lang":"bash","label":"Install Pyarmor"}],"dependencies":[{"reason":"Commonly used with Pyarmor to package obfuscated scripts and their runtime dependencies into a single executable for distribution.","package":"PyInstaller","optional":true}],"imports":[{"note":"This is the entry point within an obfuscated script, dynamically loaded at runtime. The `pyarmor` tool itself is primarily a command-line interface.","symbol":"__pyarmor__","correct":"from pyarmor_runtime import __pyarmor__"}],"quickstart":{"code":"pyarmor gen foo.py\npython dist/foo.py","lang":"bash","description":"Obfuscate a Python script named `foo.py` and then run the obfuscated version located in the `dist` directory. This command creates `dist/foo.py` and an essential `pyarmor_runtime` package (or `pytransform` in older versions) that must be distributed with the obfuscated script."},"warnings":[{"fix":"Review Pyarmor 9.0 upgrade notes on official documentation. For CI/CD, consider obtaining a Pyarmor CI license or updating existing license configurations (e.g., regfiles for Group License).","message":"Pyarmor 9.0+ introduced significant changes to licensing for CI/CD pipelines. Pyarmor Pro licenses can no longer be used in CI/CD, requiring a new Pyarmor CI license. Basic licenses need an extra CI regfile. Users upgrading Group Licenses must regenerate device regfiles.","severity":"breaking","affected_versions":"9.0.0 and later"},{"fix":"Always run obfuscated scripts with the exact Python version and platform (architecture, OS) that was used to obfuscate them. Use `--platform` option for cross-platform obfuscation if pre-built runtimes are available for the target.","message":"Obfuscated scripts, especially those utilizing C extensions (`_pytransform`), are often platform and Python version-dependent. Running scripts obfuscated with one Python version (e.g., 3.8) on a different version (e.g., 3.7 or 3.9) can lead to crashes or 'Marshal loads failed' errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that the entire `dist` directory content (including `pyarmor_runtime` and `license.lic`) is distributed. Verify that `pyarmor_runtime` is in Python's import path on the target system. When using tools like PyInstaller, ensure they correctly bundle these runtime files.","message":"The `pyarmor_runtime` package (or `pytransform` in older versions) and the `license.lic` file are crucial runtime dependencies. Failing to distribute these files with your obfuscated scripts, or placing them where Python cannot find them, will result in runtime errors such as `NameError: name '__pyarmor__' is not defined` or `Could not find _pytransform`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Manually ensure all existing configuration and project rule files are explicitly encoded as `utf-8` or convert them if issues arise. Review file content for non-UTF-8 characters if problems persist.","message":"Starting with Pyarmor 9.2.2, default encoding for configuration files (`pyarmor cfg`) and project rule files changed to `utf-8`. Older configurations might implicitly rely on locale-specific encodings, potentially causing issues when reading or writing these files with the updated version.","severity":"gotcha","affected_versions":"9.2.2 and later"},{"fix":"Thoroughly test obfuscated scripts across all target Python versions and platforms, especially when using advanced obfuscation modes. If crashes occur, try disabling the most aggressive modes or check for the latest Pyarmor patches that address specific Python version compatibility issues. Refer to `When Things Go Wrong` section in documentation for troubleshooting.","message":"Certain advanced obfuscation modes (e.g., BCC, RFT, `--mix-str`) have historically encountered issues, including script crashes on specific Python versions (e.g., Python 3.9+, 3.12, 3.13) or platforms. While fixes are often released in subsequent patches, aggressive obfuscation can introduce subtle runtime bugs.","severity":"gotcha","affected_versions":"Various, depending on specific mode and Python version"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}