I'm making a program in python, but once I'm finished with the program, will the users have to download the python environment in order to use my program, or will it work without the python environment once compiled? Also, will it automatically be cross-platform or will I have to download a conversion program to make it work for Linux, Mac OS and Windows? I'm new to the language so this is confusing me.
Many Linux systems come with Python installed already. However, there are some tools to help if it is not:
pyinstaller for Windows, Linux, and Mac OS X (does not work for Python 3)
bbfreeze for Windows and Linux
py2exe for Windows
Freeze for Linux
py2app for Mac OS X
Have a look at py2exe for windows, linux and mac is likely to have it preinstalled.
They would need a python interpreter to use your program unless you turn your python script into a windows executable. One way of doing that is by using Py2exe
It depends on what 3rd party libraries you include in your program.
For example I never managed to make a windows executable with the PyQt lib,
by using py2exe. But this was 2-3 years ago and things might have changed.
Also don't hardcode paths in your program and make use of functions like os.path.join
Don't make assumptions about config files and stuff. Do check on runtime the platform
your program is running on and act accordingly.
In general, your biggest problem will be the Windows platform.
Related
I developed a Desktop Application in Python on my Mac using PyCharm.
Then I used pyinstaller to pack it and try to use it on Windows 10 and Windows 7 but when I try to run on windows 10 i have the error :
This app can’t run on your PC check with software publisher.
I tried to set every possible setting on windows 10, from SmartScreen to security policy to allow external developer. Nothing. So I thought could be something about pyinstaller.
Ideas?
PyInstaller is not cross platform.
See the documentation here., specifically the Note near the top of the page.
If you want to run on Windows, you must compile on Windows. Same for Mac OS and Linux.
Solutions to your particular problem:
Simply use a different machine to compile, with the relevant OS, if available.
A virtual machine on your Mac (VirtualBox for example) with Windows installed inside it.
As far as I know, there is no other way around this. No tricks or clever hacks... Sorry!
Is it possible to use pyWin32 without installing it?
I would like to include it into python's interpreter folder.
I have managed to use Python interpreter without installing it (simply installing it and copy&pasting installed directory into my product).
I need also the same with pyWin32.
My objective is:
Client receives a folder with a script (batch) which will run python program in a console. The client does not have to install python, pywin32, nothing. What he needs is to copy and paste my product and run the console-based program.
Is it possible?
My objective is: Client receives a folder with a script (batch) which
will run python program in a console. The client does not have to
install python, pywin32, nothing. What he needs is to copy and paste
my product and run the console-based program.
I would suggest something along the lines of using pyinstaller or any other python code to executable converter.
http://www.pyinstaller.org/
PyInstaller is a program that freezes (packages) Python programs into
stand-alone executables, under Windows, Linux, Mac OS X, FreeBSD,
Solaris and AIX. Its main advantages over similar tools are that
PyInstaller works with Python 2.7 and 3.3—3.5, it builds smaller
executables thanks to transparent compression, it is fully
multi-platform, and use the OS support to load the dynamic libraries,
thus ensuring full compatibility.
To me it seems this would suit your/your clients needs quite well. Furthermore pyinstaller is easy to use.
I'm trying to build an application written in python, which can run on Windows without the need to install python or associated libraries(standalone), and I want to do that on my mac. I tried Pyinstaller, but it seems to generate files executable only in a platform that is building the application(in this case, osx).
Is there easy way out like Pyinstaller or do I have to do that in a very complex way? Since I'm not the expert, the latter option might be impossible for me to do. Would it be more wise just to try to build the app on windows than mac using pyinstaller?
For pyinstaller, they have clearly mentioned that packaging Windows binaries while running under OS X is NOT supported, and recommended to use Wine for this.
1. Can I package Windows binaries while running under Linux?
No, this is not supported. Please use Wine for this, PyInstaller runs
fine in Wine. You may also want to have a look at this thread in the
mailinglist. In version 1.4 we had build in some support for this, but
it showed to work only half. It would require some Windows system on
another partition and would only work for pure Python programs. As
soon as you want a decent GUI (gtk, qt, wx), you would need to install
Windows libraries anyhow. So it's much easier to just use Wine.
2. Can I package Windows binaries while running under OS X?
No, this is not supported. Please try Wine for this.
3. Can I package OS X binaries while running under Linux?
This is currently not possible at all. Sorry! If
you want to help out, you are very welcome.
I wrote a script which I wish to deploy on Mac OS, Windows and Linux clients. While most Mac and Linux machines have some version of Python, Windows does not. Adding to this there's a module partly written in C that I wish to include.
Currently I'm looking into freezing the code (e.g. py2exe or PyInstaller), but this will get tedious on changes.
Is there a good alternative to ship the script in one self-contained package?
I hope my title was clear. I'm using wxpython for making a GUI and I want it to be able to be opened, extracted, and have it work on all operating systems. I was able to include twill by finding a folder called twill inside the twill archive, which worked fine. However, I'm unable to figure out how to correctly package wxpython.
EDIT: I'm not using either. py2exe is only for windows, and bbfreeze doesn't seem to work on mac (so it's not cross platform)
Unfortunately, there's just no one stop solution so that a single installable executable will work across all operating systems. The right solution is really to provide a different installer or executable for each OS; For windows, use py2exe, for mac, py2app is a good choice, and for linux you should just provide a tarball with a reasonable setup.py (that you will need for the first two, anyway).
You should go with the recommendation of TokenMacGuy. But I preferrably would use a tool which is able to freeze the application for all OS instead of using different ones.
cx_freeze is a good choice regarding these terms.
This is another fine alternative:
PyInstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, and Mac OS X. Its main advantages over similar tools are that PyInstaller works with any version of Python since 2.2, it builds smaller executables thanks to transparent compression, it is fully multi-platform, and use the OS support to load the dynamic libraries, thus ensuring full compatibility.
Have you tried http://cx-freeze.sourceforge.net/ ?