Bundling Python script to run on different Macs - python

I wrote a Python script that scrapes PDFs that are in the same directory as the file itself.
I used pyinstaller on my Mac to convert this to a onefile .exe on my MacBook Pro and it works great. However, when I try to send this file to someone else via email, it doesn't open because "it's a Windows file", despite the fact that it was compiled/bundled on a Mac. The modules I use are regex, PyPDF2, among other non-standard libraries. How do I make these executables run on different computers?
I've tried using auto-py-to-exe, but to no avail.
The executables work as built on my Mac, but when I email it to someone whose Mac does not have Python/IDLE installed, I run into a wall. If it makes a difference, I've made a version for Windows, and that works great, too.

AFAIK, you need to compile Python programs separately for each environment. If you're on Linux, give crossenv a try.
If you aren't on Linux, to build packages that work on a Mac without IDLE installed, try py2app.
You can also suggest that whoever you're sending this file to install wine, which will let them run the .exe (though installing python might be a tad easier for them.)

Related

How to create Linux and MacOS executables using PyInstaller on Windows?

I used Pyinstaller to make a standalone portable application for windows from python code, and it works normally.
I understand that to create an executable for a certain OS it must be done on that specific OS.
Is there a way to create executables for other platforms directly from windows without running a virtual machine.
Thank you.
Since pyinstaller is not a cross-compiler (which means with pyinstaller you cannot create an executable for any other system than the one you are on), you will have to look for other tools.
On the official github FAQ, they recommend using Wine for this specific purpose.
Link to FAQ.
Since you don't want to look for other systems to compile your code on, this seems to be the only option.
if you have docker-expertise, you could try to get the docker-containers in the following link to do the job for you (creating the executable for windows/linux by setting up a docker-container for each target-system) and starting up the Docker-Containers for Building the Executables from within your Windows-OS. I have not tryed it out though, but the Readme of the project sounds promising.
https://github.com/cdrx/docker-pyinstaller
If the project does what it says, you would only need to execute the following two commands in your project-folder to create the executables for Windows and Linux, when you have gotten everything setted up:
docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows
docker run -v "$(pwd):/src/" cdrx/pyinstaller-linux
In order to make executable files for Mac and Linux, you need to build it on the same systems
For example, in order to make your Linux work, you need to collect the rpm package
No, pyinstaller isn't a cross-compiler, so just use VM.

Making a python standalone Linux executable on windows

I have a python server application that I wish to put onto my server. I have tried to run the python scripts on my server, I moved the file with sftp and I installed the dependancies with pip. No luck, it doesn't use my modules even after I install them. It says the module I installed isn't a thing, when when I run pip again it says it is already there. I read about standalone executables a little, but I only found documentation on windows ones. I know Linux cannot run exe files, but is there something similar.
Another thing might be my unfamiliarity with pip. I use the terminal in py charm which automatically puts my pip modules into files. When I do that on my ubuntu machines there is no file created in my directory. (Feels like a problem to me)
So I don't want to leave this open in case anyone else see this and needs help. I had forgotten to install my modules, so I did that, and then to run my two programs I just use screen now to host different terminals for each program. It isn't very hard.

Creating an exe file for windows using mac for my Kivy app

I've created a kivy app that works perfectly as I desire. It's got a few files in a particular folder that it uses. For the life of me, I don't understand how to create an exe on mac. I know I can use pyinstaller but how do I create an exe from mac.
Please help!
For pyinstaller, they have stated that packaging Windows binaries while running under OS X is NOT supported, and recommended to use Wine for this.
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.
Can I package Windows binaries while running under OS X?
No, this is not supported. Please try Wine for this.
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.
This is easy with Pyinstaller. I've used it recently.
Install pyinstaller
pip install pyinstaller
Hit following command on terminal where file.py is path to your main file
pyinstaller -w -F file.py
Your exe will be created inside a folder dist
NOTE : verified on windowns, not on mac

Pyinstaller - Standalone .exe

I am trying to create an .exe file such that when run on any windows 10 pc will run without requiring any installations. What I tried using was:
pyinstaller --onefile main.py
I ran the exe file on a friend's computer and it turns out that it required first python2.7 to be installed, then it said that modules weren't installed i.e; no module named datetime found. The executable finally ran after I installed all dependencies on my friend's computer but the whole point of creating .exe file was useless, I might as well have just typed python main.py after doing so much. Is there an appropriate way I could get an .exe file from .py which wont require anything to be installed? Like an actual standalone app. Thank you!
Actually this should work. I never had problems with pyinstaller, yet. Maybe reinstall pyinstaller or make sure to use the newest version. Also try first of all an easy "helloWorld"
input("hello from Console.\nPress Enter to close it :)")
Just tried this one on a colleague's machine that has no python installed. And it worked well.
I've had good results using the pyinstaller module to one file even when running code with multiple dependencies on machines without python installed. Reading the documentation helped There is a comprehensive list of python to exe compilers in another stackoverflow question: a good python to exe compiler?

Making your python code execute on all computers

I have written a python GUI application.I want to run the code on my friend's computer who doesn't have python interpreter in his computer and that he can't download since he can't connect to the internet.How do I make that happen?
Use py2exe (for Windows), py2app (for Mac), or cx_freeze (for Linux) to bundle the Python interpreter, your program, and the standard library into an executable you can use on a machine with no Python at all.
PS: If your friend's computer isn't on the Internet, however you'd get him your program, you can also get him the kits for Python, etc.
py2exe is a library that allows you to compile Python executables for Windows. There's also cx_Freeze, which is cross-platform.

Categories

Resources