Run script written in Python in windows (No python installed)

Asked

Viewed 6,545 times

1

I have a script written in Python(3.6) that works normally if run on my PC(which has Python installed)

My question is: If I run it on some other windows that doesn’t have python installed, will it run normally? And if it doesn’t work, there is some way to make it run without having to install python in the other windows?

  • Unfortunately not. Since Python is not a native language of Windows, it cannot identify the syntax of the script to be able to interpret it. Have you searched for an embedded version?

  • Hmm understood, a pity then, I thought I had some form. But thank you.

  • You can call the direct Python interpreter as a function in C. This implies you write your own program that calls the interpreter, but it’s close enough

3 answers

4


You can "package" python along with your script, by your question, it seems to me that the most appropriate would be a "python Compiler", two interesting options are:

Nuitka:

TL;DR
Nuitica is a python compiler, compatible with Python 2.6, 2.7, 3.2, 3.3, 3.4, and 3.5 You feed it with your python application and it does the "magic" by converting the app into an executable.

Pyinstaller:

Pyinstaller is a program that "packages" python applications into a standard executable in Windows, Linux, Mac OS X, Freebsd, Solaris, and AIX environments. Its main advantage over competitors: supports Python versions from 2.7 to 3.5, and, thanks to the transparent compression technique, creates small executables.

  • An error appears when running Nuitka: "Error, cannot find "gendef.exe" which is required though."

  • See if that answer, help you.

  • I haven’t been able to solve it yet, could it be because my script was done in Python 3.6 ?

  • I managed to run the Pyinstaller, it packed into a folder and turned into an exe. the problem is that if I take the exe inside this folder it does not run. Has some command for me to pack these other files inside the exe too?

  • I got it here, I just had to add --onefile at the end. Thanks for the help.

0

One solution would be for you to distribute along with the executable, some files needed for the execution of the Script on Windows. You can get these files by downloading the embedded package available on the Python downloads page: clicking here. In the file that will be downloaded, there are several other files, but for your need you can leave only the three files that would be: python.exe, python36.dll, python36.zip

I hope I’ve helped.

  • Complementing... the file to be downloaded would be the one of the title: "Windows x86 embeddable zip file"

  • I’ll try to do that

0

One way is to use the auto-py-to-exe clicking here, you can choose whether to run on command line or as a windows "interface".

Make sure you have python up to version 3.7 (3.8 requires another way to install different).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.