r/pythonhelp • • Jan 09 '23

Running Python reliably on a Windows computer without installing Python

This is probably going to sound a little convoluted, but this might be a solution to a problem I'm encountering with Python software I'm creating and distributing at work...

I'm wondering...instead of creating an executable or installing Python using its normal installer file, I thought maybe I could manually copy over the Python interpreter and associated files, including the Lib and the Scripts folder. The interpreter and associated files will already be configured properly (e.g., any needed libraries will already be installed).

On this computer, I want to create a batch file for the user to run my code. (It'd just point to the Python interpreter and to the Python code I've written.)

I tested this and it seems to work...I know this probably sounds like a needlessly complicated process, but it may be simpler than my alternatives.

Is this likely to work reliably, or are there problems I'm going to encounter here that I haven't thought of?

Thanks!

2 Upvotes

4 comments sorted by

View all comments

1

u/carcigenicate Jan 09 '23

instead of creating an executable . . . I thought maybe I could manually copy over the Python interpreter and associated files

This is what it does when you create an executable (assuming you aren't compiling the Python down to native bytecode). It just packages the interpreter with your code.

1

u/therealdeal6 Jan 10 '23

I'm trying to avoid locked-down computers requiring administrator permission to run the software, and these computers require admin passwords to run any executable. They do not require passwords to run a batch file.

I described this as one computer, but it'd be many, many computers. I can easily get the Lib and Scripts folders, my code, and a batch file into these computers and easily update those remotely if needed. Using an executable will work but would require IT to allow the executables to run on all computers. If I can avoid exe files altogether, it's likely to be a much easier and faster setup process. And possibly easier to maintain.

I'm also considering just compiling them as executables and updating (replacing) them remotely, if needed. But it's extra work for IT for all those computers to allow the executable to even run in the first place.

I'm just thinking outside the box. Wanted to know if it would work at all or if it'd just create extra problems later.