33

I have some .py files I wrote that I want to run on a different machine. The target machine does not have python installed, and I can't 'install' it by policy. What I can do is copy files over, run my stuff, and then remove them.

What I tried was to just take my development python folder over to the target machine and cd to the python folder and run python.exe /path/to/.py/file. It gave me an error saying that python.dll was not registered. If I registered the DLL that is probably going to move me to far across the 'violating policy' line.

Is there anyway I can accomplish running python files on a machine that does not have python actually installed (trying to get py2exe to work now, but it is painful)?

6 Answers 6

16

I decided to go with cx_Freeze.

It created a distro that I was able to simply copy and move to the target machine. Also, it was much easier to use than py2exe; further it seems that it is still being maintained (as of Mar 10, 2011), while py2exe development does not look as active.

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

2 Comments

Is it possible to pass arguments for the packaged script? using cx_freeze
As of April 2018 cx_Freeze is still supported. The only issue I had is that the example says to call their custom script (placed in Scripts) and I had to add a .py extension to the file for Windows 7 to recognize and run it.
9

Edit: Development of Portable Python has stopped. I will remove this answer shortly.

Check out Portable Python. That should do what you need.

Current versions (as of April 2015) are 2.7.6 and 3.2.5

6 Comments

Looks interesting, but possible show stopper that it supports three versions of Python 2.5.4, 2.6.1 and 3.0.1. Thanks
You mean you need 2.7.1 or 3.1/3.2? I'm sure they are in development already.
Yes, for me 2.7.1, but I'll keep watching that site. Thanks
im at 2.7.1 also, so Ill keep an eye on it, but it can't help me now. Also looking at cx_Freeze, but first shot out of the gate had issues
The link says that Portable Python isn't being developed anymore. WinPython might be a viable alternative.
|
7

Check out PyInstaller. It's easier to work with than py2exe (at least for simple applications).

2 Comments

Is it possible to pass arguments for the packaged script? using Pyinstaller
@pyd yes, you can use option -c when running pyinstaller --onefile -c myscript.py
1

WinPython might be what you need. It needs to be unpacked using an installer, but the unpacked files can be run out of the box on any machine without any installation.

As of October 2015 it's being actively maintained.

1 Comment

Is it possible to pass arguments for the packaged script? using Winpython
0

This is an old question, but one alternative is creating a virtual environment for Python, which can be as simple as python -m venv myenvname (Python 3.4). You can "install" packages into it the normal way (e.g. pip) without needing anything else. You'll end up with a folder you can move/delete at your leisure.

2 Comments

moving the venv folder does not make it work. you will need to match the distributions, OS etc
Well, shoot. I guess I got lucky with it.
0

It seems virtualenv does not let you easily relocate the virtual environment folder created.

Check virtualenv User Guide. So moving the folder elsewhere may not work. Have you tried the relocate option with virtualenv?

Comments

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.