Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run Python without installation (without using packagers like py2exe)?

We have a complex tool (coded in Python) for environment validation and configuration. It runs on various Windows flavors. We used this tool within the company so far. However now we want our support engineers to use it on the road. The problem is they will not have permissions to install Python in customer machines.

To address this situation, we looked at utilities like py2exe, cx_freeze and pyInstaller. While they are good, the generated EXE runs into dependency issues in some situations. So we dropped using these tools.

Is it possible to take all python related files in a pen drive and run it directly from it? When we do that, obviously the interpreter complains because the DLLs are not registered on the target machine. I suspect just registering the DLLs may lead to other problems. Is there a simple solution to this?

like image 302
nLogN Avatar asked Jul 24 '26 11:07

nLogN


1 Answers

Suppose your script is main.py,

  • copy all the contents of python directory to the directory it reside in
  • search python*.dll in your windows directory and it to project/python
  • create project/main.bat:

main.bat

"%~dp0/python/python.exe" "%~dp0/main.py" %*

The project directory should be:

project
├── python
|   ├── python.exe
|   ├── python27.dll
|   └── ...
├── main.py
└── main.bat

Now, invoke the program with main.bat

like image 96
napuzba Avatar answered Jul 26 '26 02:07

napuzba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!