|
4 | 4 |
|
5 | 5 | The `telegram_selector` module must be explicitly included when building with PyInstaller. |
6 | 6 |
|
7 | | -### Option 1: Use the Hook File (Recommended) |
| 7 | +### Option 1: Use the Spec File (Recommended) |
8 | 8 |
|
9 | | -The project includes a PyInstaller hook file at `hooks/hook-app.gui.widgets.telegram_selector.py`. |
10 | | - |
11 | | -When building with PyInstaller, use the `--additional-hooks-dir` flag: |
| 9 | +The project includes a `main.spec` file that explicitly includes all necessary modules. |
12 | 10 |
|
| 11 | +Build with: |
13 | 12 | ```bash |
14 | | -pyinstaller --additional-hooks-dir=hooks main.py |
| 13 | +pyinstaller main.spec |
15 | 14 | ``` |
16 | 15 |
|
17 | | -### Option 2: Use Hidden Imports |
| 16 | +For Windows (console version), edit `main.spec` and change `console=False` to `console=True`. |
18 | 17 |
|
19 | | -Alternatively, you can use the `--hidden-import` flag: |
| 18 | +### Option 2: Use the Hook File |
20 | 19 |
|
21 | | -```bash |
22 | | -pyinstaller --hidden-import=app.gui.widgets.telegram_selector main.py |
23 | | -``` |
24 | | - |
25 | | -### Option 3: Create a Spec File |
26 | | - |
27 | | -Create a `main.spec` file with hidden imports: |
| 20 | +The project includes a PyInstaller hook file at `hooks/hook-app.gui.widgets.telegram_selector.py`. |
28 | 21 |
|
29 | | -```python |
30 | | -# -*- mode: python ; coding: utf-8 -*- |
| 22 | +When building with PyInstaller, use the `--additional-hooks-dir` flag: |
31 | 23 |
|
32 | | -a = Analysis( |
33 | | - ['main.py'], |
34 | | - pathex=[], |
35 | | - binaries=[], |
36 | | - datas=[], |
37 | | - hiddenimports=['app.gui.widgets.telegram_selector'], |
38 | | - hookspath=['hooks'], |
39 | | - ... |
40 | | -) |
| 24 | +```bash |
| 25 | +pyinstaller --onefile --noconsole --additional-hooks-dir=hooks --hidden-import=app.gui.widgets.telegram_selector main.py |
41 | 26 | ``` |
42 | 27 |
|
43 | | -Then build with: |
| 28 | +### Option 3: Use Hidden Imports Only |
| 29 | + |
44 | 30 | ```bash |
45 | | -pyinstaller main.spec |
| 31 | +pyinstaller --onefile --noconsole --hidden-import=app.gui.widgets.telegram_selector main.py |
46 | 32 | ``` |
47 | 33 |
|
48 | | -## Complete Build Command Example |
| 34 | +## Complete Build Command Example (Windows) |
49 | 35 |
|
50 | 36 | ```bash |
51 | 37 | pyinstaller \ |
52 | 38 | --name=telegram-multi-account-sender \ |
53 | 39 | --onefile \ |
54 | | - --windowed \ |
| 40 | + --noconsole \ |
55 | 41 | --icon=assets/icons/favicon.ico \ |
56 | 42 | --additional-hooks-dir=hooks \ |
57 | 43 | --hidden-import=app.gui.widgets.telegram_selector \ |
| 44 | + --hidden-import=PyQt5 \ |
| 45 | + --hidden-import=PyQt5.QtCore \ |
| 46 | + --hidden-import=PyQt5.QtGui \ |
| 47 | + --hidden-import=PyQt5.QtWidgets \ |
58 | 48 | --add-data "app/translations;app/translations" \ |
59 | 49 | --add-data "assets;assets" \ |
60 | 50 | main.py |
61 | 51 | ``` |
62 | 52 |
|
| 53 | +## Troubleshooting |
| 54 | + |
| 55 | +If you still get the "No module named 'app.gui.widgets.telegram_selector'" error: |
| 56 | + |
| 57 | +1. **Use the spec file**: `pyinstaller main.spec` (most reliable) |
| 58 | +2. **Check the hooks directory**: Ensure `hooks/hook-app.gui.widgets.telegram_selector.py` exists |
| 59 | +3. **Verify the file exists**: Check that `app/gui/widgets/telegram_selector.py` exists |
| 60 | +4. **Clean build**: Delete `build/` and `dist/` directories, then rebuild |
| 61 | +5. **Check PyInstaller version**: Ensure you're using a recent version of PyInstaller |
| 62 | + |
| 63 | + |
0 commit comments