# How to compile GUI after making changes to code

**URL:** <https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611>\
**Category:** AVR Drone Software\
**Created:** [October 3, 2023, 9:48pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611 "2023-10-03T21:48:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![HPT1-Row\_Dyer](https://avatars.discourse-cdn.com/v4/letter/h/ce7236/32.png) [@HPT1-Row\_Dyer](https://forum.theavr.org/u/HPT1-Row_Dyer)\
**Post date:** [October 3, 2023, 9:48pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/1 "2023-10-03T21:48:51Z")

</div>

How can I go about compiling the GUI into a .exe file after making changes to the GUI code.

Sincerely,  
HPBT-1

---

<div class="post-metadata">

**Author:** ![Jack\_Ewing](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.theavr.org/jack_ewing/32/29_2.png) [@Jack\_Ewing](https://forum.theavr.org/u/Jack_Ewing)\
**Post date:** [October 3, 2023, 10:50pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/2 "2023-10-03T22:50:29Z")

</div>

if your just changing the GUI code you should be able to run app.py from .venv and have the code run. why are you compiling to exe?

---

<div class="post-metadata">

**Author:** ![HPT1-Row\_Dyer](https://avatars.discourse-cdn.com/v4/letter/h/ce7236/32.png) [@HPT1-Row\_Dyer](https://forum.theavr.org/u/HPT1-Row_Dyer)\
**Post date:** [October 4, 2023, 1:54am UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/3 "2023-10-04T01:54:02Z")

</div>

We wanted to be able to compile it to help mitigate the chances of a single fault point - if we compile it then we can distribute the .exe file to all computers so in case one fails, another team members laptop can be used.

---

<div class="post-metadata">

**Author:** ![Jack\_Ewing](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.theavr.org/jack_ewing/32/29_2.png) [@Jack\_Ewing](https://forum.theavr.org/u/Jack_Ewing)\
**Post date:** [October 4, 2023, 9:08pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/4 "2023-10-04T21:08:32Z")

</div>

as far as I know there is not a built in way to compile it to .exe you could do something like this [https://datatofish.com/executable-pyinstaller/](https://datatofish.com/executable-pyinstaller/) to compile

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.theavr.org/nathan/32/4_2.png) [@nathan](https://forum.theavr.org/u/nathan)\
**Post date:** [October 5, 2023, 12:59am UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/5 "2023-10-05T00:59:17Z")

</div>

Inside the GUI folder of the repo, there is a [`build.py`](https://github.com/bellflight/AVR-2022/blob/main/GUI/build.py) script which compiles the GUI into an .exe.  
This uses [PyInstaller](https://pyinstaller.org/en/stable/).

---

<div class="post-metadata">

**Author:** ![HPT1-Row\_Dyer](https://avatars.discourse-cdn.com/v4/letter/h/ce7236/32.png) [@HPT1-Row\_Dyer](https://forum.theavr.org/u/HPT1-Row_Dyer)\
**Post date:** [October 7, 2023, 3:25pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/6 "2023-10-07T15:25:07Z")

</div>

So I have been trying to do this, yet every single time I run it, PyInstaller runs successfully, then when I navigate to the .exe file and run it, a cmd window opens for a fraction of a second then disappears. I have run it for both our modified code and the downloaded AVR repo. I also noticed that it added 2 separate folders “dist” and “build”, however the documentation said I could find the working .exe in “dist”, but running either has the same result. One other thing of note - the size of “dist” or the .exe inside it is significantly lower than the ~64MB of the provided GUI.exe

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.theavr.org/nathan/32/4_2.png) [@nathan](https://forum.theavr.org/u/nathan)\
**Post date:** [October 7, 2023, 7:14pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/7 "2023-10-07T19:14:31Z")

</div>

Do your modifications work when you run `app.py` directly and not compiled?

You should be using the .exe file in the `dist` folder. The `build` folder are temporary files used by PyInstaller as it compiles.

You can run the .exe directly from the command line to see what the output from the console window is before it crashes.

 ![image](https://canada1.discourse-cdn.com/flex007/uploads/avr/original/1X/17dfeefd3d4b6a99722bef3d81184dd7e57a683f.png)

---

<div class="post-metadata">

**Author:** ![HPT1-Row\_Dyer](https://avatars.discourse-cdn.com/v4/letter/h/ce7236/32.png) [@HPT1-Row\_Dyer](https://forum.theavr.org/u/HPT1-Row_Dyer)\
**Post date:** [October 7, 2023, 7:36pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/8 "2023-10-07T19:36:32Z")

</div>

Can’t comment on if the modifications work when I run app.py directly (will reach out to our programming lead and reply when I hear back) but what I do know is that I tried run it in CMD, yet I never got a single message, and when I even tried to add logging into it, the same thing happened. I will upload the “dist” folder in case it helps at all. Will also add that I am on windows if it makes any difference.

---

<div class="post-metadata">

**Author:** ![HPT1-Row\_Dyer](https://avatars.discourse-cdn.com/v4/letter/h/ce7236/32.png) [@HPT1-Row\_Dyer](https://forum.theavr.org/u/HPT1-Row_Dyer)\
**Post date:** [October 7, 2023, 7:43pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/9 "2023-10-07T19:43:21Z")

</div>

[in the attached link](https://drive.proton.me/urls/S224FY1F1W#KRIL6pRmfwBv) I went ahead and uploaded the entire AVR-2022-stable file, its not our modified one, just the one straight off of the AVR-2022 github, the .exe file is located under GUI \> dist \> build then the .exe file is under there. I made it by going into the gui folder using cmd, then running pyinstaller on the build.py script

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.theavr.org/nathan/32/4_2.png) [@nathan](https://forum.theavr.org/u/nathan)\
**Post date:** [October 8, 2023, 6:37pm UTC](https://forum.theavr.org/t/how-to-compile-gui-after-making-changes-to-code/611/10 "2023-10-08T18:37:47Z")

</div>

I downloaded your folder, went into the GUI subfolder, and the `dist\app\app.exe` did not run for me. I was able setup a virtual environment, build, and run and executable with no issue:

```bash
python -m venv .venv
.venv\Scripts\activate
python -m pip install pip wheel --upgrade
python -m pip install -r requirements.txt
python build.py # if this not a git repo, edit line 12 to just be `"AVRGUI",`
.\dist\AVRGUI.exe

```

I used Python 3.10.10 on Windows 11.
