-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
464 lines (424 loc) · 25.4 KB
/
index.html
File metadata and controls
464 lines (424 loc) · 25.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Complete Python to Executable Guide</title>
<meta name="description" content="Complete guide for converting Python scripts to standalone executables using PyInstaller, auto-py-to-exe, cx_Freeze, and Nuitka.">
<meta name="keywords" content="Python, executable, PyInstaller, auto-py-to-exe, cx_Freeze, Nuitka, conversion, guide">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-dark.min.css" rel="stylesheet"
id="prism-dark" disabled>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Floating Table of Contents -->
<div class="floating-toc" id="floatingToc">
<h6>Quick Navigation</h6>
<a href="#overview" class="toc-item">Overview</a>
<a href="#comparison" class="toc-item">Tool Comparison</a>
<a href="#pyinstaller" class="toc-item">PyInstaller</a>
<a href="#auto-py-to-exe" class="toc-item">auto-py-to-exe</a>
<a href="#cx-freeze" class="toc-item">cx_Freeze</a>
<a href="#nuitka" class="toc-item">Nuitka</a>
<a href="#troubleshooting" class="toc-item">Troubleshooting</a>
</div>
<!-- Scroll to Top Button -->
<button class="scroll-to-top" id="scrollToTop" onclick="scrollToTop()">
<i class="fas fa-arrow-up"></i>
</button>
<main class="main-container">
<!-- Hero Section -->
<div class="hero-section">
<h1 class="hero-title">
Python to Executable
</h1>
<p class="hero-subtitle">
Complete guide for converting Python scripts to standalone executables
</p>
<!-- Dark Mode Toggle -->
<button id="modeSwitch" onclick="toggleMode()" class="btn btn-outline-dark mt-4" aria-label="Toggle dark mode">
<i class="fas fa-moon"></i>
</button>
</div>
<!-- Navigation Pills -->
<ul class="nav nav-pills nav-fill" id="methodTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="overview-tab" data-bs-toggle="pill" data-bs-target="#overview"
type="button">
Overview
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="comparison-tab" data-bs-toggle="pill" data-bs-target="#comparison"
type="button">
Compare Tools
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="methods-tab" data-bs-toggle="pill" data-bs-target="#methods" type="button">
Methods
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="troubleshooting-tab" data-bs-toggle="pill"
data-bs-target="#troubleshooting" type="button">
Troubleshooting
</button>
</li>
</ul>
<!-- Tab Content -->
<div class="tab-content" id="methodTabsContent">
<!-- Overview Tab -->
<div class="tab-pane fade show active" id="overview" role="tabpanel">
<div class="content-card">
<h2>Quick Start</h2>
<div class="success-box">
<strong>TL;DR:</strong> For most users, PyInstaller is the easiest option:
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>pip install pyinstaller<br>pyinstaller --onefile your_script.py</code>
</div>
</div>
<h3>Why Convert Python to Executable?</h3>
<div class="row">
<div class="col-md-4">
<div class="text-center p-3">
<i class="fas fa-users tool-icon text-primary"></i>
<h5>Easy Distribution</h5>
<p>Share your app without requiring Python installation</p>
</div>
</div>
<div class="col-md-4">
<div class="text-center p-3">
<i class="fas fa-shield-alt tool-icon text-success"></i>
<h5>Source Protection</h5>
<p>Protect your code from easy reverse engineering</p>
</div>
</div>
<div class="col-md-4">
<div class="text-center p-3">
<i class="fas fa-cog tool-icon text-info"></i>
<h5>System Integration</h5>
<p>Easy integration with schedulers and automation</p>
</div>
</div>
</div>
</div>
</div>
<!-- Comparison Tab -->
<div class="tab-pane fade" id="comparison" role="tabpanel">
<div class="content-card">
<h2>Tool Comparison</h2>
<!-- Tool Cards -->
<div class="row mb-4">
<div class="col-lg-3 col-md-6 mb-3">
<div class="card tool-card position-relative">
<span class="difficulty-badge difficulty-easy">Easy</span>
<div class="card-body text-center">
<i class="fas fa-box tool-icon text-primary"></i>
<h5>PyInstaller</h5>
<p class="small">Most popular, works out-of-the-box</p>
<ul class="list-unstyled text-start small">
<li><i class="feature-icon fas fa-check"></i>Great compatibility</li>
<li><i class="feature-icon fas fa-check"></i>Easy to use</li>
<li><i class="feature-icon fas fa-times text-danger"></i>Larger files</li>
</ul>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6 mb-3">
<div class="card tool-card position-relative">
<span class="difficulty-badge difficulty-easy">Easy</span>
<div class="card-body text-center">
<i class="fas fa-desktop tool-icon text-success"></i>
<h5>auto-py-to-exe</h5>
<p class="small">GUI wrapper for PyInstaller</p>
<ul class="list-unstyled text-start small">
<li><i class="feature-icon fas fa-check"></i>Visual interface</li>
<li><i class="feature-icon fas fa-check"></i>Beginner friendly</li>
<li><i class="feature-icon fas fa-times text-danger"></i>Same limitations as
PyInstaller</li>
</ul>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6 mb-3">
<div class="card tool-card position-relative">
<span class="difficulty-badge difficulty-medium">Medium</span>
<div class="card-body text-center">
<i class="fas fa-tachometer-alt tool-icon text-warning"></i>
<h5>cx_Freeze</h5>
<p class="small">Fast startup, native installers</p>
<ul class="list-unstyled text-start small">
<li><i class="feature-icon fas fa-check"></i>Faster startup</li>
<li><i class="feature-icon fas fa-check"></i>Native installers</li>
<li><i class="feature-icon fas fa-times text-danger"></i>More setup required
</li>
</ul>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6 mb-3">
<div class="card tool-card position-relative">
<span class="difficulty-badge difficulty-hard">Hard</span>
<div class="card-body text-center">
<i class="fas fa-rocket tool-icon text-danger"></i>
<h5>Nuitka</h5>
<p class="small">True compilation, best performance</p>
<ul class="list-unstyled text-start small">
<li><i class="feature-icon fas fa-check"></i>Fastest execution</li>
<li><i class="feature-icon fas fa-check"></i>Better security</li>
<li><i class="feature-icon fas fa-times text-danger"></i>Complex setup</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Detailed Comparison Table -->
<table class="table comparison-table">
<thead>
<tr>
<th>Metric</th>
<th>PyInstaller</th>
<th>cx_Freeze</th>
<th>Nuitka</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Build Time</strong></td>
<td><span class="badge bg-success">⚡ Fast</span></td>
<td><span class="badge bg-warning">🐌 Slower</span></td>
<td><span class="badge bg-danger">🐌🐌 Slowest</span></td>
</tr>
<tr>
<td><strong>Startup Time</strong></td>
<td><span class="badge bg-warning">🐌 Slow</span></td>
<td><span class="badge bg-success">⚡ Fast</span></td>
<td><span class="badge bg-success">⚡⚡ Fastest</span></td>
</tr>
<tr>
<td><strong>File Size</strong></td>
<td><span class="badge bg-success">📦 Small</span></td>
<td><span class="badge bg-warning">📦📦 Larger</span></td>
<td><span class="badge bg-danger">📦📦📦 Largest</span></td>
</tr>
<tr>
<td><strong>Security</strong></td>
<td><span class="badge bg-danger">🔒 Low</span></td>
<td><span class="badge bg-danger">🔒 Low</span></td>
<td><span class="badge bg-success">🔒🔒🔒 High</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Methods Tab -->
<div class="tab-pane fade" id="methods" role="tabpanel">
<div class="content-card">
<h2>Conversion Methods</h2>
<!-- PyInstaller Method -->
<div class="mb-5" id="pyinstaller">
<h3>Method 1: PyInstaller (Recommended)</h3>
<h4>Setup Process</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code># Create virtual environment<br>python -m venv venv<br><br># Windows<br>venv\Scripts\activate<br><br># macOS/Linux<br>source venv/bin/activate<br><br># Install dependencies<br>pip install -r requirements.txt<br>pip install pyinstaller</code>
</div>
<h4>Basic Usage</h4>
<div class="row">
<div class="col-md-6">
<h5>Simple Conversion</h5>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i
class="fas fa-copy"></i></button>
<code>pyinstaller your_script.py</code>
</div>
</div>
<div class="col-md-6">
<h5>Single File</h5>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i
class="fas fa-copy"></i></button>
<code>pyinstaller --onefile your_script.py</code>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h5>GUI Application</h5>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i
class="fas fa-copy"></i></button>
<code>pyinstaller --onefile --windowed your_script.py</code>
</div>
</div>
<div class="col-md-6">
<h5>With Custom Icon</h5>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i
class="fas fa-copy"></i></button>
<code>pyinstaller --onefile --icon=app.ico your_script.py</code>
</div>
</div>
</div>
</div>
<!-- auto-py-to-exe Method -->
<div class="mb-5" id="auto-py-to-exe">
<h3>Method 2: auto-py-to-exe (GUI)</h3>
<div class="info-box">
<strong>Perfect for beginners!</strong> This provides a visual interface for PyInstaller.
</div>
<h4>Installation & Usage</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>pip install auto-py-to-exe<br>auto-py-to-exe</code>
</div>
<h4>Configuration Steps</h4>
<ol>
<li><strong>Script Location:</strong> Browse and select your <code>.py</code> file</li>
<li><strong>Onefile:</strong> Choose "One File" for single executable</li>
<li><strong>Console Window:</strong> Select "Window Based" for GUI apps</li>
<li><strong>Icon:</strong> Optional - add a custom <code>.ico</code> file</li>
<li><strong>Additional Files:</strong> Add any data files your script needs</li>
<li><strong>Convert:</strong> Click "CONVERT .PY TO .EXE"</li>
</ol>
</div>
<!-- cx_Freeze Method -->
<div class="mb-5" id="cx-freeze">
<h3>Method 3: cx_Freeze (Fast Startup)</h3>
<h4>Installation</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>pip install cx_freeze</code>
</div>
<h4>Setup Script (setup.py)</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>from cx_Freeze import setup, Executable<br><br>build_options = {<br> 'packages': [],<br> 'excludes': [],<br> 'include_files': []<br>}<br><br>executables = [<br> Executable('your_script.py', base='Win32GUI')<br>]<br><br>setup(<br> name='YourApp',<br> version='1.0',<br> options={'build_exe': build_options},<br> executables=executables<br>)</code>
</div>
<h4>Build Commands</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code># Build executable<br>python setup.py build<br><br># Create Windows installer<br>python setup.py bdist_msi</code>
</div>
</div>
<!-- Nuitka Method -->
<div class="mb-5" id="nuitka">
<h3>Method 4: Nuitka (Performance)</h3>
<div class="warning-box">
<strong>Advanced users only!</strong> Requires C compiler installation.
</div>
<h4>Prerequisites & Installation</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code># Windows: Install MinGW64 or Visual Studio<br># macOS: Install Xcode command line tools<br># Linux: Install GCC<br><br>pip install nuitka</code>
</div>
<h4>Basic Usage</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code># Compile to executable<br>python -m nuitka --onefile your_script.py<br><br># GUI application<br>python -m nuitka --onefile --windows-disable-console your_script.py<br><br># With optimizations<br>python -m nuitka --onefile --enable-plugin=anti-bloat your_script.py</code>
</div>
</div>
</div>
</div>
<!-- Troubleshooting Tab -->
<div class="tab-pane fade" id="troubleshooting" role="tabpanel">
<div class="content-card">
<h2>Troubleshooting</h2>
<h3>Common Issues & Solutions</h3>
<div class="mb-4">
<h4>ImportError: Module not found</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code># Add hidden imports<br>pyinstaller --hidden-import=module_name your_script.py</code>
</div>
</div>
<div class="mb-4">
<h4>Missing Data Files</h4>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code># Include data files<br>pyinstaller --add-data "data_folder;data_folder" your_script.py<br><br># Use this in your Python code:<br>import sys<br>import os<br><br>def resource_path(relative_path):<br> if hasattr(sys, '_MEIPASS'):<br> return os.path.join(sys._MEIPASS, relative_path)<br> return os.path.join(os.path.abspath("."), relative_path)</code>
</div>
</div>
<div class="mb-4">
<h4>Large File Sizes</h4>
<div class="info-box">
<strong>Tips to reduce executable size:</strong>
<ul class="mb-0">
<li>Use virtual environments (most important!)</li>
<li>Exclude unnecessary modules with <code>--exclude-module</code></li>
<li>Use UPX compression</li>
<li>Consider using <code>--onedir</code> instead of <code>--onefile</code></li>
</ul>
</div>
</div>
<div class="mb-4">
<h4>Antivirus False Positives</h4>
<div class="warning-box">
<strong>Solutions:</strong>
<ul class="mb-0">
<li>Add exclusions to your antivirus</li>
<li>Use code signing certificates</li>
<li>Consider Nuitka for better reputation</li>
<li>Submit to antivirus vendors for whitelisting</li>
</ul>
</div>
</div>
<h3>Debugging Tips</h3>
<div class="success-box">
<ol class="mb-0">
<li><strong>Test in --onedir mode first</strong> for easier debugging</li>
<li><strong>Run executable from command line</strong> to see error messages</li>
<li><strong>Use --log-level=DEBUG</strong> for verbose output</li>
<li><strong>Check build/warn-*.txt files</strong> for warnings</li>
</ol>
</div>
</div>
</div>
</div>
<!-- Footer -->
<div class="content-card mt-4">
<div class="row">
<div class="col-md-6">
<h5>Additional Resources</h5>
<ul class="list-unstyled">
<li><a href="https://pyinstaller.readthedocs.io/" target="_blank">PyInstaller Docs</a></li>
<li><a href="https://cx-freeze.readthedocs.io/" target="_blank">cx_Freeze Docs</a></li>
<li><a href="https://nuitka.net/doc/user-manual.html" target="_blank">Nuitka Manual</a></li>
</ul>
</div>
<div class="col-md-6">
<h5>Acknowledgments</h5>
<ul class="list-unstyled">
<li>PyInstaller Team</li>
<li>cx_Freeze Developers</li>
<li>Nuitka Project</li>
<li>auto-py-to-exe</li>
</ul>
</div>
</div>
<hr>
<div class="text-center">
<p class="mb-0">
Licensed under MIT License |
<a href="#" class="text-decoration-none">Contribute on GitHub</a>
|
<strong>Star this guide if it helped you!</strong>
</p>
</div>
</div>
</main>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Prism.js for syntax highlighting -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script src="script.js"></script>
</body>
</html>