python yourfile.py
You have to have python installed first. It will automatically compile your file into a .pyc binary, and then run it for you. It will automatically recompile any time your file changes.
http://www.python.org/download/
Answer from Paul McMillan on Stack Overflowpython yourfile.py
You have to have python installed first. It will automatically compile your file into a .pyc binary, and then run it for you. It will automatically recompile any time your file changes.
http://www.python.org/download/
Python compiles its files to bytecode before executing them. That means you have to have a Python interpreter installed on the target machine.
If you don't want to install Python on the target machine use py2exe, py2app or something similar.
compilation - Can I somehow "compile" a python script to work on PC without Python installed? - Stack Overflow
How can I compile my python code for Windows in Linux?
How to build and install Python from source on Windows on the command line?
How do i recompile for windows?
Here is one way to do it (for Windows, using py2exe).
First, install the py2exe on your Windows box.
Then create a python script named compile.py, like this:
import sys
from distutils.core import setup
import py2exe
entry_point = sys.argv[1]
sys.argv.pop()
sys.argv.append('py2exe')
sys.argv.append('-q')
opts = {
'py2exe': {
'compressed': 1,
'optimize': 2,
'bundle_files': 1
}
}
setup(console=[entry_point], options=opts, zipfile=None)
To compile your Python script into a Windows executable, run this script with your program as its argument:
$ python compile.py myscript.py
It will spit out a binary executable (EXE) with a Python interpreter compiled inside. You can then just distribute this executable file.
PyInstaller has worked well for me, generating reasonably small packages due to its use of upx. Its dependency detection was better than py2exe at the time as well. It seems not to have a lot of recent development and probably doesn't work with 3.x, however.
The source in the repository is a better starting point than the 1.4 package.
Also see the wiki page about working with Python 2.6+.
From the features list:
- Packaging of Python programs into standard executables, that work on computers without Python installed.
- Multiplatform: works under Windows (32-bit and 64-bit), Linux (32-bit and 64-bit) and Mac OS X (32-bit only for now, see MacOsCompatibility).
- Multiversion: works under any version of Python from 1.5 up to 2.7. NOTE: If you're using Python 2.6+ on Windows, see Python26Win.
- Flexible packaging mode:
- Single directory: build a directory containing an executable plus all the external binary modules (.dll, .pyd, .so) used by the program.
- Single file: build a single executable file, totally self-contained, which runs without any external dependency.
- Custom: you can automate PyInstaller to do whatever packaging mode you want through a simple script file in Python.
- Explicit intelligent support for many 3rd-packages (for hidden imports, external data files, etc.), to make them work with PyInstaller out-of-the-box (see SupportedPackages).
- Full single-file EGG support: required .egg files are automatically inspected for dependencies and bundled, and all the egg-specific features are supported at runtime as well (entry points, etc.).
- Partial directory EGG support: required .egg directories are automatically inspected for dependencies and bundled, but egg-specific features will not work at runtime.
- Automatic support for binary libraries used through ctypes (see CtypesDependencySupport for details).
- Support for automatic binary packing through the well-known UPX compressor.
- Optional console mode (see standard output and standard error at runtime).
- Windows-specific features:
- Support for code-signing executables.
- Full automatic support for CRTs: no need to manually distribute MSVCR*.DLL, redist installers, manifests, or anything else; true one-file applications that work everywhere!
- Selectable executable icon.
- Fully configurable version resource section and manifests in executable.
- Support for building COM servers.
- Mac-specific features:
- Preliminar support for bundles (see MacOsCompatibility)
Pyinstaller giving me Linux executables.
i don't have any experience with python that is worth anything. got sent a program for a school project, but it was made in Python and set up for linux. i have to compile it and i have no idea about how that works and need help.
in the message i got with the files, the creator writes " it was set up to work only on my specificLinux machine. You will probably have to recompile things to make it work." Having searched on the internet for how to do this, i haven't found anything that gave me a good idea about what i should do.
i would prefer not to send the files in this thread if anyone asks, out of respect to the creator, as i don't know if he would like that.
Edit: people seem to understand me not wanting to share it in this thread as i don't want to share it at all. i have no problem with doing in in dms, i just don't want to do it publicly