I\'m writing a program on a computer running Ubuntu with an x86-64 processor that needs to run on a computer running OS X with an x86 processor. I\'m probably not going to be ab
You can't do this as the python executable you use on Ubuntu is not going to run on OS X, even if the architecture is the same.
If you're trying to distribute a Python program without installation, you could look at something like PyInstaller. You'll still need access to a machine running OS X to generate the app bundle, but you should be able to package up everything into a .app bundle that is launched like a standard OS X application.
Virtualenvs are not a packaging mechanism. There is no reason a virtualenv should ever leave the computer it was created on. It won't work, the virtualenv is 100% specific to your OS, CPU architecture, Python version, etc.
There are a number of solutions for packaging. The old and still current way is specifying dependencies in setup.py
, and running setup.py install
on the target machine. Note that this can happen inside a virtualenv, you just have to create the virtualenv and run setup.py in there. Both virtualenv and the standard library venv
in 3.3 provide ways of doing this automatically after virtualenv creation.
If you absolutely must create a binary distribution (e.g. because you need an extension module and the end user doesn't have a compiler), you need an egg or a wheel or one of the .py-to-binary converters (py2exe, PyInstaller, cx_Freeze, etc.). You will need access to an OS X machine to create that. And at least the wheel and the egg are usually installed anyway, so using them doesn't save you any of this hassle. That's because they are formats for binary distribution, their primary purpose is pushing the build step from the end user to the developers, not to remove the installation step.
In summary: Just create a script which creates a virtualenv and installs your application as well as the required libraries.