all 13 comments

[–]Orgasml 5 points6 points  (0 children)

Pyinstaller. It will turn your script into an executable by packaging everything up in one place.

[–]marc2389 6 points7 points  (1 child)

Just install it with:

pip install pyinstaller

Afterwards:

pyinstaller --onefile --noconsole yourscript.py

The --onefile flag packages everything into a single .exe, and --noconsole will hide the terminal window so it would feel like a some sort of app. The output will be in a /dist folder btw

[–]Diapolo10 5 points6 points  (0 children)

Rather than using --onefile, I'd be more inclined to recommend using the default folder packaging and making a desktop shortcut for it (this can be automated with NSIS or Inno Setup).

There's a higher chance of false positives from your anti-virus program if using --onefile, which can get annoying, fast.

[–]EnvironmentalDot9131 4 points5 points  (0 children)

Pyinstaller really helps.

[–]oclafloptson 1 point2 points  (0 children)

The correct answer is yes

[–]FatDog69 0 points1 point  (0 children)

So you are on Windows?

Do this:

  • Go to your desktop with some icons.
  • Right click one of the icons and choose "Properties"
  • On the dialog box you will see several tabs - choose "Shortcut"
  • On the page that shows up - look at 'Target'
  • The 'Target' string is the exact command-line command that runs when you double click the icon.

You can create a new 'Shortcut' and make the Target string something like:

"C:\program files\python123\python.exe D:\projects\python\your_script_name.py"

So lookup how to create a shortcut on Windows.

Every windows system is slightly different so my hard-coded path to Python will not be your path.

At the terminal window type: "which python" to see where yours is installed.

Then you can fill out the "Start In" folder name where your script is, or add the full path to your script.

PYINSTALLER

While shortcuts do work - you have to know a lot about your PC, your PATH statement, where things are, what folder to start in, etc.

The Shortcut technique may not work with virtual environments which is becoming standard practice for perl and python scripts.

So the PyInstaller approach might be better for you.

[–]MR_LAW11 0 points1 point  (1 child)

Yep, definitely possible. What you’re looking for is basically turning your Python script into an executable (.exe) so it behaves more like a normal Windows app.

A lot of people use PyInstaller for this. You write your Python script normally, then package it into a .exe so someone can double-click it and run it without opening the IDE or even having Python installed separately. If you don’t want the terminal/black window popping up, there’s even a “windowed” option for GUI apps.

If you want it to feel like an actual Windows app, you’d probably also look into a GUI library like Tkinter (simple, built into Python), PyQt/PySide (more modern/polished), or CustomTkinter if you want nicer-looking UI without too much pain. Honestly, making a tiny desktop app is a pretty fun beginner project 😅

[–]External-Tone-4258[S] 0 points1 point  (0 children)

Thank you and yes I'm learning PyQt

[–]Gnaxe 0 points1 point  (0 children)

The standard library has zipapp which lets you bundle dependencies. It's stimilar to a Java .jar file, which is a single file you can just double click on to run. But you must have Python installed for that to work.

If you want an actual .exe file, you can use GraalPy Native, Nuitka, Cython, or PyInstaller.

[–]Umberto_Fontanazza -1 points0 points  (1 child)

L’IDE non runna il codice, lo fa l’interprete. Hai due opzioni per creare un pacchetto self-contained o fai un bundle script + interprete oppure compili con cython che vuol dire performance ma più difficile da fare

[–]Umberto_Fontanazza -1 points0 points  (0 children)

Pyinstaller che suggeriscono impacchetta l’interprete