Git Product home page Git Product logo

pythonexe's Introduction

Python EXE Maker

This little project shows you how to build an executable file of your Python code.

Here, hello.py is the main file. It uses a module (helper.py), it imports the os module from the stdlib, and it even uses a 3rd-party library (requests).

With PyInstaller, you can easily create a single executable file from this project.

$ pyinstaller --onefile hello.py

Under Windows you might have a problem with this. If the .exe complains that a DLL is missing, then try this variation:

$ pyinstaller --onefile --noupx hello.py

You'll find the exe in the dist/ folder.

Why would you need an EXE?

EXE is a file extension for an executable file format. It makes distributing your program much easier. The exe produced by PyInstaller is standalone. It means that it's enough to give this exe to your friend and (s)he can run it right away. There is no need to install Python on his/her machine, no need to create a virtual environment, etc. Under Windows you can simply start an exe with a double click.

Of course, if your friend uses Windows (Linux), then create the exe under Windows (Linux).

Will my EXE run faster?

No. PyInstaller simply creates a bundle that contains everything: your code, the necessary modules / packages, the virtual environment, the Python interpreter, etc. When you launch the EXE, it is extracted to your temp folder (under Linux it's the /tmp folder), and your application is started from there. So the runtime will be approximately the same.

For a demo, check out my simple Fibonacci implementation in the folder speed_test.

pynt

pynt is a minimalistic build tool. If you installed everything with poetry (poetry install), then you can also create the executable with the following commands:

$ pynt exe

or (using pyinstaller's --noupx switch)

$ pynt exe2

Video

Click on the image below to open a YouTube video that shows you everything step-by-step:

view demo on YouTube

Changes since the video was made:

  • The project was updated for Python 3.8 and PyInstaller 4.0.
  • In the video I talk about pipenv, but the project was updated to use poetry. I tried both pipenv and poetry and I prefer poetry.

Links / News / Related Work

pythonexe's People

Contributors

dependabot[bot] avatar jabbalaci avatar ssanidhya24-git avatar vishu7758 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.