3

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?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
nLogN
  • 53
  • 4
  • Which dlls need to be registered ? – napuzba Sep 29 '16 at 12:24
  • python27.dll is where it started – nLogN Sep 29 '16 at 12:32
  • Running WinPython on a USB-stick should work, doesn't it? For sure, you have to be careful with paths etc., since there won't be any environment variables. – nostradamus Sep 29 '16 at 13:03
  • WInPython could be a solution. However our application does not run out of the box since it uses PyGtk. I did not find an easy way to get PyGtk with WinPython. Another issue is WinPython targets scientific computing and has a large set of libraries which we may not want. – nLogN Sep 30 '16 at 03:42

1 Answers1

1

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

napuzba
  • 6,033
  • 3
  • 21
  • 32
  • I was hoping this would work! Unfortunately it does not. It gives the same error as before. The python DLL is still not registered with Windows. – nLogN Sep 30 '16 at 04:27
  • Find `python*.dll` in your windows directory and copy it to `project/python` directory. – napuzba Sep 30 '16 at 06:18
  • Awesome, I got it working! Thanks @napuzba. For others who want to try this: note that python27.dll is not in the installation folder but in **C:\Windows\System32**. – nLogN Oct 03 '16 at 09:25