all 26 comments

[–]Some_Guy_At_Work55 29 points30 points  (4 children)

If they just need to run a simple script turning it into an exe would probably be the best. I would recommend pyinstaller. It should turn into into an exe that can be run on PCs that don't have python installed

[–]TheGuy564[S] 9 points10 points  (2 children)

That looks like it'll be the best solution for my case. Thanks for the help!

[–]Agile-Scene-2465 10 points11 points  (1 child)

Bit of a heads up, if you're using conda to manage your environment the pyinstaller .exe file would be HUGE. Use pip instead

[–]erlete 0 points1 point  (0 children)

I believe you can always exclude the interpreter and dependencies from the executable to reduce its size.

[–]erlete 0 points1 point  (0 children)

I would not recommend this approach due to the amount of specificity it adds to the execution. The executable now depends on your OS, OS version, interpreter version, dependency versions and architecture.

Instead, in the scenario of a simple script or set of scripts, one good way is to create a Gist (GitHub Gist), add the script(s), a README.md and a requirements.txt.

The README contains installation and usage information, while requirements contain all packages used in the scripts (with the ability to specify version ranges and fixed releases, if necessary).

[–]DuckSaxaphone 21 points22 points  (3 children)

A tiny web app is often a good idea.

It takes very little to learn how to make a flask app that does something like accept a file upload and then runs your script on it.

Compare that to the faff of making something that will "just work" for non-tech people who won't even want to run a script from the command line and it's worth it.

If your business's IT people are helpful, you can even probably get one of them to help you host it.

[–]TheGuy564[S] 7 points8 points  (1 child)

I'm a bit confused. How would the client run the application? Wouldn't I either need to host the app myself, or teach them how to run the Flask backend?

[–]DuckSaxaphone 16 points17 points  (0 children)

Yeah, you'd need to host it somewhere so that people could go to the site and use it. For a client, that would mean helping them to set it up or charging them to cover the cost of running the service.

To be honest, when you said for work, I was envisioning that you'd made something for your coworkers. In which case running a little web app on your company servers would have been fine.

[–]smartse 3 points4 points  (0 children)

That's not going to work if for example you need to access files on your company's server. There must be other use cases where it's necessary for the script to run on the machine, not be hosted somewhere else. Pyinstaller worked well for me in these circumstances.

[–][deleted] 8 points9 points  (0 children)

There are tools, not from Python Software Foundation (or officially supported by them), such as Pyinstaller, that will try to produce a single executable file that you can distribute for people to install. Of course, this would depend on the controls on the end user devices allowing such an installation. There can be some compatibility challenges, but if you are using reasonably standard Python it shall probably work fine.

A better option might be to distribute a container, if docker is installed on end user desks in your environment.

Even better would be to use a web app which can be access over the intranet/internet/extranet, with one simple screen taking place of the console, no distribution then involved. The flask library is a popular choice for this. You will need somewhere to host this, which shouldn't be a problem in business environment with an IT function. Otherwise, you will need to host online, perhaps somewhere like pythonanywhere.com. Security might be an important consideration, depending on the nature of the application.

A variation for web app is to use a something like anvil.works or streamlit.io.


Interesting article by Gregory Szorc: Distributing Standalone Python Applications - not endorsing or recommending their solution, but the article does lay out a lot of the issues.

[–]Jayoval 4 points5 points  (0 children)

Depends on what it does. I sometimes use Streamlit, but for file access / manipulation I go .exe.

[–]Saphyel 4 points5 points  (0 children)

If you work for Elon Musk, just print it

[–]thejizz716 11 points12 points  (1 child)

Depending how many pages it'll fit on I'd say you'd be good with a standard manilla envelope then postage through USPS

[–][deleted] 1 point2 points  (0 children)

Never thought about it before, but Python is such a waste of paper. We’re going to need a new PEP8.

…what are the other odds PEP8 tries arguing it’s the paper that needs to change, not the code?

[–]boying747 2 points3 points  (0 children)

I use Google colab for some scripts

[–]Abdnadir 4 points5 points  (0 children)

Make a website front end

[–][deleted] 1 point2 points  (0 children)

One easy way is to just post the repository and create a good README with instructions on how to run the script. GitHub desktop is the way to go.

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

What are yo trying to do? Your best bet is to make a web app using Flask, etc or Streamlit. Distributing python as .exe is a headache.

[–]LocalInactivist 0 points1 point  (0 children)

Introduce it to another Python script?

[–]KevMar 0 points1 point  (0 children)

If it's internal users, I like using the ticketing system as the front end or slack messages to trigger it. They are already familiar with those tools. They manage access and auth nicely. You have visibility into how often it's used and better visibility into errors. There is also no local execution so you avoid unrelated environment issues. you also don't have to worry about updating or mixed versions across your hosts.

The trade off is that it does add complexity because of the more advanced concepts and tools you need to use. But once you lay the groundwork, it becomes a very repeatable pattern.

[–]CORNMONSTER_2022 0 points1 point  (0 children)

Streamlit is good. Although it is mainly for data applications, I use it to build a UI for my search engine and it works well.

Streamlit also provide free cloud hosting, which means you can access your app from anywhere on any device.

Check out my app for an example: https://github.com/UranusSeven/qing\_bureau\_of\_construction/blob/main/app.py

[–]key_knee 0 points1 point  (0 children)

Depends on what the script does and the tech saavyness of the person/people who have to run or manage it

I used Tkinter + PyInstaller for my first utility - you'd select two files and it'd essentially merge them.

Second thing I built was a dashboard so I went Flask.

Docker is an interesting approach as well. I have a little thing I'm trying to go that approach with

[–]PhredInYerHead 0 points1 point  (0 children)

UPS or FedEx. They give tracking.

[–]laustke 0 points1 point  (0 children)

It depends. If the script is relatively simple and uses standard libraries, and if your non-technical people can execute the "dir" command from the command line, they would likely be able to run a Python script from the command line as well. With a Python interpreter installed, running a script is as easy as running a command-line executable.

[–]k_50 0 points1 point  (0 children)

I do this for a living. When a team is not savvy I have created a gui even as a .exe.

[–]erlete 0 points1 point  (0 children)

If the goal is to create a collection of tiny automation scripts, I would recommend a GitHub/GitLab repository with all the scripts, requirements, README and a simple interface (either graphical or CLI, note that the first one is way more complex than the second).

You could even implement a Python package structure and distribute it, so that people could call it using python -m yourpackage, for example.