Installation¶
This guide explains how to install the KnitPkg CLI for MetaTrader (kp).
KnitPkg is Windows-first, because MetaTrader and MetaEditor run natively on Windows. Linux is also supported via Wine.
Prerequisites¶
Before installing kp, make sure you have:
-
MetaTrader 4 and/or MetaTrader 5. Available at: https://www.mql5.com/.
-
Git client. KnitPkg leverages Git for MetaTrader package & project management, so a Git client is essential. Available at: https://git-scm.com/.
-
Windows Terminal updated (applicable for Windows only). Windows 11 already includes it. On older Windows versions, you may need the newer terminal to correctly render the CLI’s UTF-8 symbols and formatting. Available in Microsoft Store: https://aka.ms/terminal. For other installation methods see https://github.com/microsoft/terminal.
Option A: Using the prebuilt executable¶
Windows native installation¶
- Download the latest
kp.exefrom the project’s GitHub Releases. - Put
kp.exein a folder you control (example:C:\tools\knitpkg\). - Add that folder to your PATH so
kpcan be called from any terminal. - Verify the installation. Open a new terminal and run:
If the command is not found, PATH is not set correctly (or the terminal session needs to be restarted).
Antivirus false positive (kp.exe)
Some antivirus products (including Windows Defender) may flag kp.exe as a threat due to a false positive.
kp.exe is not malicious software. The full source code is publicly available on GitHub, and the kp.exe published on the Releases page is automatically generated by GitHub Actions.
We are working to fix this issue by obtaining a certificate to sign the executable so it will be recognized as a legitimate program with no threats.
As a temporary workaround, if you use one of the affected antivirus products, disable it while using kp.exe or follow Option B (PyPI) below, which installs KnitPkg via pip and does not trigger antivirus warnings.
Linux Installation (via Wine)¶
KnitPkg supports Linux by running MetaEditor compiler through Wine. The kp binary runs natively on Linux and invokes the MetaEditor compiler via your Wine/MetaTrader environment.
Prerequisites¶
- Wine with a working MetaTrader 5 (or MetaTrader 4) installation inside a Wine prefix. Should you follow the instructions at MetaTrader 5 on Linux, you already have it.
- Git client available at: https://git-scm.com/.
Step 1: Download the prebuilt binary¶
- Download the latest
kp(Linux binary) from the project's GitHub Releases. - Put
kpin a folder you control (example:~/bin/knitpkg/). - Make it executable:
Step 2: Set environment variables¶
Add the following to your shell profile (~/.bashrc, ~/.zshrc, etc.):
WINEPREFIXmust point to the Wine prefix where MetaTrader is installed.- Add the folder containing
kptoPATHso it can be called from any terminal.
Reload your shell or run source ~/.bashrc (or equivalent) to apply the changes.
Step 3: Configure KnitPkg¶
On Linux, all paths passed to kp config or kp globalconfig must be POSIX paths (forward slashes), even when pointing to files inside the Wine prefix. For example:
kp config --mql5-compiler-path "/home/<user>/.mt5/drive_c/Program Files/MetaTrader 5/MetaEditor64.exe"
Verify the installation¶
Option B: Via PyPI¶
You can install KnitPkg from PyPI using pip. Windows or Linux with Python 3.13 or higher are required.
(Optional, recommended) Create a virtual environment first:
Then install the package:
To upgrade to the latest version:
Verify the installation:
Note
Step3 above applies if you're installing KnitPkg on Linux via PyPI.