---
title: "Discussion on \"Electron + Django ( Part 2 ), package it to production\" | Hashnode"
description: "Discussion on \"Electron + Django ( Part 2 ), package it to production\". Detail guide of packaging Electron Django app by pyinstaller and electron forge"
url: "https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Electron + Django ( Part 2 ), package it to production](https://ivanyu2021.hashnode.dev/electron-django-part-2-package-it-to-production?utm_source=hashnode&utm_medium=feed)

Detail guide of packaging Electron Django app by pyinstaller and electron forge

May 9, 2022 · 9 min read · ivanyu2021.hashnode.dev  
Read the article

-   [#django](https://hashnode.com/tag/django)
-   [#electron](https://hashnode.com/tag/electron)
-   [#desktop](https://hashnode.com/tag/desktop)
-   [#python](https://hashnode.com/tag/python)
-   [#typescript](https://hashnode.com/tag/typescript)

## Written by

[Ivan Yu](https://hashnode.com/@ivanyu2021)

@ivanyu2021

  
[View profile](https://hashnode.com/@ivanyu2021)

Programming

## Responses 5

Markdown supported · ⌘↵ to post

[Vincent Pawlowski](https://hashnode.com/@Vince2202)

[Feb 17, 2024](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/65d01fe7ad8c313aed9c3a2d)

Ivan Yu, thank you so much for the post. I did Part 1 with not much trouble... However, on Part 2, I am struggling to package the django app using Pyinstaller... No matter what I try, I get the following error:

PyInstaller.exceptions.PythonLibraryNotFoundError: Python library not found

Even when I want to package a very simple python app in a venv virtual env, I get this error... Any idea why ? Thank you

[KimSia Sim](https://hashnode.com/@Kimsia)

[Sep 13, 2023](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/650124aa1310dfd331e26268)

I’m late to this post. Thanks for writing this, [Ivan Yu](https://hashnode.com/@ivanyu2021)

My name is Kimsia and I’m a Django web dev based in Singapore. I came across this by chance via googling.

I’m also interested in building a desktop app (preferably cross platform on Mac, windows, etc) while leveraging on my Django abilities.

Is there a community for like-minded people (like everyone here in this thread) to discuss our various attempts to do this?

[Vincent Pawlowski](https://hashnode.com/@Vince2202)

[Feb 17, 2024](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/650124aa1310dfd331e26268#reply-65d01edd09be2438fe6eefbe)

Hi Kimsia. I am also based in Singapore and have a strong interest in Desktop App using a Frontend (like vue 3 js Electron) and Django as backend. I have been looking for joining s community like you describe. would be happy to connect.

[Ivan Yu](https://hashnode.com/@ivanyu2021), thank you so much for the post. I did Part 1 with not much trouble... However, on Part 2, I am struggling to package the django app using Pyinstaller... No matter what I try, I get the following error:

PyInstaller.exceptions.PythonLibraryNotFoundError: Python library not found

Even when I want to package a very simple python app in a venv virtual env, I get this error... Any idea why ? Thank you

[KimSia Sim](https://hashnode.com/@Kimsia)

[Feb 19, 2024](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/650124aa1310dfd331e26268#reply-65d2d78a4e5432264d7d5e9b)

[Vincent Pawlowski](https://hashnode.com/@Vince2202) ping me on discord `kimsia#3035`

[James Sugjin Kahng](https://hashnode.com/@jahmezz)

[Apr 28, 2023](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/644b7685eeb64393a9977aab)

After a bit of fiddling around, I got everything to work in Part 2 and I'll share the issues I found and resolved here.

#1: The src/build/afterExtract.js python copy folder function doesn't seem to work.

Update: This is a pathing issue it seems. The source folder should have the additional \\edtwExample\\ to reach the actual dist folder. Your Github repo adds a parent folder with .bat files which makes the existing path invalid.

#2: I found other pathing issues that make it not work right out of the box.

For example, the edtwExample.spec in the python folder points to edtwExample\\manage.py, but the manage.py is in the same folder as the spec file.

#3: The spawn command for production doesn't seem to run properly. I got a number of issues, but the approach I write here in "Edit" works.

Edit: The previous way didn't work all the time. Here is a guaranteed way.

const serverPath = path.join(app.getAppPath(),"..","..","python", "edtwExample.exe") const command = `"${serverPath}" runserver --noreload`; return spawn(command, { shell: true, });

You need a stable path to work from. spawn on Node.js is based on the path your command line is calling processes from.

I used app.getAppPath().

[James Sugjin Kahng](https://hashnode.com/@jahmezz)

[May 1, 2023](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/644b7685eeb64393a9977aab#reply-644f7bb890a163c764821d53)

And as I'm sure a lot of this post worked in past versions of these packages, here is my dependency list with their versions.

"devDependencies": { "@electron-forge/cli": "^6.1.1", "@electron-forge/maker-deb": "^6.1.1", "@electron-forge/maker-rpm": "^6.1.1", "@electron-forge/maker-squirrel": "^6.1.1", "@electron-forge/maker-zip": "^6.1.1", "@electron-forge/plugin-webpack": "^6.1.1", "@typescript-eslint/eslint-plugin": "^5.59.1", "@typescript-eslint/parser": "^5.59.1", "@vercel/webpack-asset-relocator-loader": "^1.7.3", "css-loader": "^6.7.3", "electron": "24.1.3", "eslint": "^8.39.0", "eslint-plugin-import": "^2.27.5", "fork-ts-checker-webpack-plugin": "^7.3.0", "node-loader": "^2.0.0", "style-loader": "^3.3.2", "ts-loader": "^9.4.2", "ts-node": "^10.9.1", "typescript": "~4.5.4" }, "dependencies": { "axios": "^1.4.0", "electron-squirrel-startup": "^1.0.0", "tree-kill": "^1.2.2" }

[Aitor Cereceto Benavente](https://hashnode.com/@CereDev)

[Nov 11, 2022](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/636e7b036c32db196dd6099e)

Excelent blog and work! I have a question: What about managing a DB using django as the backend? Will be the app able to make actions against the DB?

[Ivan Yu](https://hashnode.com/@ivanyu2021)

[Nov 14, 2022](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/636e7b036c32db196dd6099e#reply-6371e0fbb409cc3d17fda17f)

Yes, you can make action against the DB in Django by Django ORM, which is a built-in feature in Django. In the past, I have built a project in Django, pyinstaller and used SQLite as the DB and it runs smoothly.

Since the backend is only a Django web server but only accepts web requests from 127.0.01 and localhost, you can also install other Django plugins if you need.

[Andrii](https://hashnode.com/@Arox)

[Aug 31, 2022](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/630f08b156df9e8e5025825f)

Thanks for the great piece of work! Don't you plan to add a production Web-server like nginx or Apache to the project? It'd be great to have a self-contained and real production environment.  
What do you think? Is it possible?

Thanks.

[Andrii](https://hashnode.com/@Arox)

[Sep 29, 2022](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/630f08b156df9e8e5025825f#reply-63353b99e594fa4ba3b8b92a)

Thanks for the answer. Currently I'm developing a Django project. I plan to deploy it with pyInstaller but then I'll pack the resulting .EXE along with nginx web-server using the regular Inno Setup, a free installer for Windows. It's quite flexible, I hope, I'll manage to solve all the issues on my way ;)

[Ivan Yu](https://hashnode.com/@ivanyu2021)

[Nov 14, 2022](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/630f08b156df9e8e5025825f#reply-6371df22b409cc3d17fda138)

[Andrii](https://hashnode.com/@Arox) , hope that you can solve all the issue and complete your project

[KimSia Sim](https://hashnode.com/@Kimsia)

[Sep 13, 2023](https://hashnode.com/posts/electron-django-part-2-package-it-to-production/6278bcaec2a8c278735c8e9a/comment/630f08b156df9e8e5025825f#reply-650124d91310dfd331e26270)

[Andrii](https://hashnode.com/@Arox) did you manage to do this and write up somewhere?
