{"id":20263003,"url":"https://github.com/k-rt-dev/fastapi-pyinstaller","last_synced_at":"2026-06-08T00:31:07.282Z","repository":{"id":152804320,"uuid":"612743258","full_name":"K-RT-Dev/fastapi-pyinstaller","owner":"K-RT-Dev","description":"Basic example of using PyInstaller to compile a server based on FastAPI. For use cases where we need to create a local server simply by running an .exe","archived":false,"fork":false,"pushed_at":"2023-03-11T21:00:18.000Z","size":577,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-03T14:25:22.715Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/K-RT-Dev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-11T20:59:04.000Z","updated_at":"2025-09-03T20:42:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"880073e7-2cff-4e76-ab81-f30e969bdaa1","html_url":"https://github.com/K-RT-Dev/fastapi-pyinstaller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/K-RT-Dev/fastapi-pyinstaller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Ffastapi-pyinstaller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Ffastapi-pyinstaller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Ffastapi-pyinstaller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Ffastapi-pyinstaller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/K-RT-Dev","download_url":"https://codeload.github.com/K-RT-Dev/fastapi-pyinstaller/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-RT-Dev%2Ffastapi-pyinstaller/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34043822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T11:32:53.106Z","updated_at":"2026-06-08T00:31:07.241Z","avatar_url":"https://github.com/K-RT-Dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Introduction\n\nBasic example of using [PyInstaller](https://pyinstaller.org/) to compile a server based on [FastAPI](https://fastapi.tiangolo.com/). For use cases where we need to create a local server simply by running an *.exe*.\n\nThe project uses [Poetry](https://python-poetry.org/) to create a Python environment.\n\nThe resulting server generates two GET endpoints on *localhost:8000*. The first one is *\"/\"* which returns a \"Hello World\". The second one is *\"/get_jpg\"* which returns a static file embedded in the compiled server.\n\nThe trick to be able to use a compiled server using PyInstaller is: \n1. Add *uvicorn* and the *.py* file that starts FastAPI as \"hiddenimports\" in the *.spec*.\n2. Make the generated *.exe* execute a Python function that then runs a *uvicorn* process. PyInstaller cannot directly execute a process with *uvicorn*.\n3. Use *freeze_support()* to avoid falling into recursive process problems.\n\nThe example includes adding a static file to the compiled server in the *.spec* file.\n\nSolution based on [this](https://github.com/iancleary/pyinstaller-fastapi) repository and [this](https://stackoverflow.com/questions/65438069/uvicorn-and-fastapi-with-pyinstaller-problem-when-uvicorn-workers1) Stackoverflow thread.\n\n### Instructions\n\n0. Make sure to have Python 3.9 installed (other versions may cause conflicts).\n1. Install [Poetry](https://python-poetry.org/) if you don't have it.\n2. Validate that it is correctly installed using: `poetry -v`\n3. Create and activate the environment with: `poetry shell`\n4. Install dependencies with: `poetry install`\n5. Run the program with Python to validate its functionality: `python main.py`. Make sure there is a response from *localhost:8000* and *localhost:8000/get_jpg*\n6. Create the build using: `pyinstaller FastApiPyInstaller.spec`\n7. The build can be found in directory */dist*. To run the program, click on \"FastApiPyInstaller.exe\"\n\nThis compilation will result in a folder with an approximate weight of 20mb. If we compress the folder using WinRar, we can achieve a weight of 9.5mb.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-rt-dev%2Ffastapi-pyinstaller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-rt-dev%2Ffastapi-pyinstaller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-rt-dev%2Ffastapi-pyinstaller/lists"}