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

1

u/Zeroflops Jan 09 '23

Better to just creat a py exe file which does all this in one executable file. Pyinstaller is one option but there are others.

An alternative would be to make your app web based and serve it from a common location.

1

u/therealdeal6 Jan 10 '23

I do think a web app would be better, but I don't have the skills to build anything like that...yet!

I'm trying to avoid exe files if I can. These have to be allowed by our IT department on all of the computers, and it could be quite a lot, since these computers are pretty locked down. Batch files do not require any kind of administrator permission.

I was just doing a little out-of-the-box thinking. I wondered if it might be a little trickier to set up initially, but in the end be easier to get out to the many computers. No need to manually allow an exe file on every machine. But it may very well just be adding extra steps to the process that aren't really justified.

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.