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?

4
  • Which dlls need to be registered ? Commented Sep 29, 2016 at 12:24
  • python27.dll is where it started Commented Sep 29, 2016 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. Commented Sep 29, 2016 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. Commented Sep 30, 2016 at 3:42

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
Find python*.dll in your windows directory and copy it to project/python directory.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.