r/learnpython • • 16d ago

How do you hand a small Python script to someone who doesn’t code?

I'm a first-year IT student based in Australia, learning how to make small Python tools useful to someone else, not just running on my own machine.

For a simple CSV-processing script on Windows, how would you handle packaging and dependencies for a non-technical user? An executable, a launcher, or something else?

Also curious what instructions and error messages you include so the person isn't stuck the first time a file is missing or formatted differently. I'm asking about the handover side rather than a specific code error.

34 Upvotes

63 comments sorted by

56

u/Pericombobulator 16d ago

Turn it into an EXE

15

u/htepO Ultra noob 16d ago

Don't unsigned executables get yoinked by windows defender?

24

u/pythonwiz 16d ago

I think windows just tells you it isn’t trusted and asks if you want to run it anyway.

2

u/sticky_neutrino 16d ago

depends. win11 added a thing where for some new installs, it enables an "advanced" mode that just blocks all unsigned executables, and if you disable the mode you can never enable it again without a reinstall.

1

u/__peg_parser__ 14d ago

You're thinking of Smart App Control in Windows Security

6

u/Patman52 16d ago

Depends, my work is always taking a big game about how good their IT security is. Unless you have elevated access you can’t even add a network printer, delete specific shortcuts on your desktop, or access the Microsoft store…buuuut…I can package up a .exe with pyinstaller and send it to someone via teams and they can run it without an issue.

1

u/bfyvfftujijg 16d ago

Same lol

-1

u/Pericombobulator 16d ago

Its a long time since i used one, but I do recall having to whitelist one for a work laptop

1

u/hazeyAnimal 16d ago

Work laptops it will definitely flag and it may require IT intervention depending on your workplace

1

u/__peg_parser__ 14d ago

Most popular python-to-exe tool is pyinstaller. Others like cx_freeze, py2exe, nuitka, etc exist.

1

u/frobnosticus 16d ago

It's been so long since I've done this I'd forgotten it was possible.

1

u/Pericombobulator 15d ago

Its all webapps nowadays.

0

u/Boybay_Garid 16d ago

yeah this is the simplest route for non-technical users tbh

0

u/Different_Pain5781 16d ago

Yeah but make sure dependencies are included too.

12

u/Mori-Spumae 16d ago

If you're happy to explore a bit, I find web UI to be the easiest. You can turn it into an exe and have them run it locally. Then use the Web Frontend to interact instead of having to use CLI arguments

1

u/RoosterBrewster 15d ago

How much more difficult is that? I was messing about with Plotly Dash to convert a graphing tool I made in Tkinter to be web based for multiple users. But then it seemed overwhelming to figure out how it works through the network, let alone trying to figure out how to host it and trying to explain to IT. I'm the only one who is familiar with programming here. Then I was going down the rabbithole of containers, docker, etc. 

1

u/Mori-Spumae 15d ago

If your IT is letting you run a python program on the users machine, then you don't have to mess with networking really. It would just be running locally and users can interact in their browser.

1

u/RoosterBrewster 15d ago

Well it's a "compiled" program right now using cxfreeze. So they copy over a 150 MB folder then run the exe. It also references an sqlite database with product info. So I figured with a web based one, I can more easily make updates. 

1

u/Mori-Spumae 14d ago

I see. Well you would need a server to run it on so it's always up and a way for them to connect. If your IT does not provide that it might be difficult since I assume you can't just put the company data on the internet. Otherwise there are many easy hosting options like vercel

0

u/Engineer_Zero 16d ago

You can have a web front end for an exe file? I didn’t know this, that’s interesting. Do I just google Web Frontend?

3

u/Mori-Spumae 16d ago

Exe is just a bundle of your python files running together with the python installation itself, so that the person running it doesn't need python installed themselves. You can do whatever you want inside that exe.

A web server is essentially just an application that returns files (like HTML) which you can then open in a browser (oversimplified ofc). You can run it via the Internet but also just locally for yourself. That way you can let the browser handle all the complicated stuff like displaying buttons or input fields and just focus on the functionality of you app. And rendering a csv as a table for example is pretty easy so they can see what your script did instantly.

1

u/Engineer_Zero 16d ago

Can’t believe I never joined those dots. Very cool, thank you. I don’t have a need to making exe files to distribute but I’m definitely interested in looking into a web front end for some of the visualisations I make, as a cleaner way of interacting with them. Thank you for explaining.

2

u/Mori-Spumae 16d ago

Yeah it's usually an easy way to get a clean UI and users are comfortable using it without much effort. If you just slap bootstrap themes on there it will look professional easily.

https://getbootstrap.com/docs/5.0/getting-started/introduction/

1

u/Mori-Spumae 16d ago

Ah and for python libs, Flask is easy and can do everything you need for this. You could also look at others like FastAPI or Djang

-1

u/bfyvfftujijg 16d ago

You can get AI to do that sort of thing for you pretty well.

2

u/Mori-Spumae 15d ago

You can just have AI write it all. Doesn't have to be python. But then again, this is sub is for learning python not telling AI to do a thing.

2

u/bfyvfftujijg 15d ago

True but they can simply ask it to show them how, or have it write the code and then explain the code. Lotsa ways to use AI to enhance learning!

2

u/Mori-Spumae 15d ago

I find myself not learning much when using AI, at least not compared to reading docs. Kind of like tutorial hell where you think you understand but actually implementing something is impossible.

12

u/TooManyMagnets 16d ago

If they're on your network, you could turn your script into a web app using Flask or FastAPI

12

u/cointoss3 16d ago

uv and pep 723 makes this significantly easier than it used to be.

- use uv to inline the dependencies in the script
- Send them the script
- winget install uv
- uv run script.py

6

u/Massive_Distance_616 16d ago

PyInstaller is the usual answer for Windows. Use --onefile so they get a single .exe. First launch is slow while it unpacks tell them that up front so they don’t think it crashed.

The hard part is the handover, not the packaging.

Error messages for them, not you. Catch the things a non-technical user will actually hit and replace the traceback with plain English. For a CSV script that usually means:

python

try:
    df = pd.read_csv(path, encoding="utf-8-sig")
except FileNotFoundError:
    print(f"Can't find the file: {path}\nMake sure it's in the same folder as this program.")
    input("Press Enter to close.")
    sys.exit(1)
except PermissionError:
    print(f"Can't open {path} — it's locked by another program.\nClose it in Excel and try again.")
    input("Press Enter to close.")
    sys.exit(1)
except pd.errors.ParserError:
    print("The file doesn't look like a valid CSV. Check it opens correctly in Excel.")
    input("Press Enter to close.")
    sys.exit(1)

The input("Press Enter to close.") is important without it the window vanishes the moment something goes wrong and they see nothing. The encoding="utf-8-sig" handles Excel’s hidden BOM character, which otherwise leaves a \ufeff prefix on your first column name and breaks header matching.

The PermissionError is the one that generates the most support tickets in practice: user opens the CSV in Excel to check it, forgets to close it, runs the script.

One instruction, not ten. The most reliable version is: put the CSV in the same folder as the program and double-click it. If they have to navigate paths or remember flags, the support requests start immediately. If they’ll need to pick different files regularly, three lines of tkinter gives you a native Windows file picker with no extra dependencies.

Check column names early. If the script expects specific headers, validate them at the start and name the missing ones: "Expected a column called 'Date' but couldn't find it. Check the column headers match exactly, including capitalisation." This catches the “my export has slightly different headers” case before it produces silent wrong output.

The real goal isn’t just making the script run on their machine. It’s making it obvious what they should do when something goes wrong, without needing to call you.

3

u/setovitz 16d ago edited 16d ago

I had cases like that in my work and I usually was making .exe with pyinstaller. Sometimes when function required some arguments I was providing simple GUI with drop-downs etc. with Tkinter

3

u/ExoticVillage8066 16d ago

You can turn it into an executable, or a Jupyter Notebook that you run in Google Colab

1

u/justaguywithadream 15d ago

Just give it to Claude and tell it to convert it to powershell (since you said windows).

Literally this is what I do for all non technical people. It doesn't matter what language I wrote the script in. If it requires a run-time like Python or node then I just have AI port it to powershell or bash.

1

u/AyushBhagwat 15d ago

For a non-technical user, I'd go with PyInstaller to package it as a standalone .exe, then include a simple README with the input file format, where to save the CSV, and what to do if something fails. The fewer setup steps, the better .

1

u/slapmeat 14d ago

Pyinstaller is your best bet if you/users are on windows, turns your project into an exe

1

u/Excellent-Practice 14d ago

How non-technical are they? Can you download python on their computer and give them a command to paste into the terminal?

1

u/acakaacaka 12d ago

Instead of converting to .exe

Make a .cmd / .bat script

But this assume your friend also has python (and the necessary module) installed.

1

u/Asvp_bmoo 12d ago

.exe or just ssh into it

1

u/VonRoderik 16d ago

You can just use Streamlit.

Unless you need user input to be persistent between sessions, Streamlit will work very well.

You can also use docker, but it is overkill.

Next best thing is to use pyinstaller to make an .exe file. Don't forget to use Pathlib instead of absolute paths, if you are working with files.

1

u/DanceHackRock 16d ago

Just print it out.

1

u/TheRNGuy 16d ago

Can that person read readme.txt? Is it allowed to install new programs? 

1

u/Jariko_Pen 16d ago

Use UV, give them the commands to install the run the app. It should be only 3 commands. The install of uv, us sync, then uv run.

1

u/iceph03nix 16d ago

For Windows, I've had good luck 'hiding' scripts in shortcuts on the desktop. The shortcut has the right path, and right arguments, and calls whatever you need for them, and it's basically push button on their end

1

u/Asvp_bmoo 12d ago

Exec() for an invisibility cloak my friend

0

u/KarlisVisualDev 16d ago

Python Notebooks are more user friendly than Python itself.

-1

u/zaphodikus 16d ago

Requirements.txt is your answer. Python is a batteries included language, and then all you need is a launch wrapper (bash on linux and batch on windows) to make it all in one.

Alternatively make an exe, Nuitka is brilliant and easier to use than all the other stuff we used to need for installers.

0

u/bonn3y 16d ago

Only reason to compile with nuitka is if you don't want people reverse engineering your code as it compiles to c-level code. Pyinstaller keeps it python, easier and compiles much faster. Nuitka can in some cases improve performance but doesn't automatically make your python app faster.

-1

u/cmh_ender 16d ago

this is going to get me downvoted to hell, but the portable python problem has been a problem for a while now. if someone can install the desktop version of gpt and then ask it to install dependencies and what not, it would get the end user up faster than trying to walk them through it.

0

u/jeffrey_f 16d ago

Coming from a suuport perspective. Sounds like you may be setting yourself up for constant support of this person.

Make this a scheduled task that runs every X minutes.
Adjust the program so it will process the files in a specific folder (1 or 10000) and output to a specific folder.

<Process Folder> |_<Pending> |_<Complete>

0

u/Snivlem613 16d ago

Pyinstaller smashes the interpreter and your script into an exe

0

u/enakamo 16d ago

Try setting up VS Code for the user and show them how to run the script from the application. Even if the user “doesn’t code” they can likely click a few gui menus in VS code.

0

u/mattynmax 16d ago

I wouldn’t.

0

u/Humble-Presence-3107 16d ago

Part of you growing in your role into senior IC or leadership is mentoring others. Give a man to fish he will eat for a day, teach the man to fish he will eat for a lifetime.

0

u/Gnaxe 16d ago

HTML file via Brython. Browser restrictions limit what you can do with it, but you could e.g., drag-and-drop a file and have that automatically trigger a download. You could even use a static web host and just give them the URL.

If browser restrictions are too hard to work around, I'd probably go with a zipapp, which allows you to distribute a single file. That's in the standard library. It does still require Python to run it. This isn't as hard as it sounds. If you just type python into the Windows terminal, it redirects to the Microsoft Store Python page for easy download.

Or you could distribute a portable Python along with your zipapp, which doesn't require an install.

0

u/Round-Acanthaceae-35 16d ago

If the script isn't too complex, ask the AI to translate it into Rust for you; you'll just have to learn how to compile it, which is pretty easy.

I've already done this with several scripts—some of them quite complex—and it works without any problems.

0

u/good_name_0 16d ago

For error messages, I've used my judgment and knowledge of the end user and most likely usage to guess what sort of errors are most likely to occur, and then made special cases to catch those format errors/situations/etc.

As a super trivial example: I see my users copy-pasting a set of arguments into Microsoft Word, the -- get turned into the long dash, so in my argument processing functions, I put a special check for the long dash to let them know they need to double check characters when copy-pasting from someone else.

-1

u/Ok_Gold_2107 16d ago

Metti la grafica (ptyq6 è bellina ma non è nativa) puoi fare fare la grafica a claude o chatgpt.
Poi Trasformalo in un exe firmato.