Hotline: 094.320.0088

Biên Dịch File Python Thành Exe

Đôi khi các bạn có nhu cầu thực thi file Python trên máy tính window. Để thực hiện download và cài đặt python trên máy tính không có cài đặn sẵn chương trình python thì ta sẽ thực hiện biên dịch file python thành file exe. Python có hỗ trợ module pyinstaller để biên dịch. Các bạn thực hiện các bước chính ở bên dưới để thực hiện.

– Bước 1: Cài dependencies bao gồm thư viện Window 10 SDK ở link bên dưới và xác định thư mục chứa các file DLL

https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk

C:\Program Files (x86)\Windows Kits\10\Redist\10.0.18362.0\ucrt\DLLs\x86

– Bước 2: Cài đặt Pyinstaller

C:\> pip install pyinstaller

– Bước 3: Ở ví dụ này ta thực hiện biên dịch chương trình LaZange ( link download ở bên dưới )

https://github.com/AlessandroZ/LaZagne

– Bước 4: Câu lệnh thực hiện câu lệnh biên dịch

C:\> pyinstaller –paths “C:\Program Files (x86)\Windows Kits\10\Redist\10.0.18362.0\ucrt\DLLs\x86”  –onefile –win-private-assemblies laZagne.py