My .app launches if i don't have the requests module imported into my app, but if it's included it crashes when trying to launch the .app compiled by py2app. I've tried to include requests into Setup.py and it still crashes.
i have py2app-0.21 installed.Running Python 3.6.4, MacOs Catalina 10.15.14
error log from console:
(org.pythonmac.unspecified.testapp.2888[62145]): Service exited with abnormal code: 255
Setup.py
from setuptools import setup
APP = ['test.py']
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'includes': ['requests'],
'packages': ['requests', 'rumps']
}
setup(
app=APP,
name='TestApp',
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
The unspecified.testapp part of your error log tells me that you need to tell python where your app file actually is (relative path? absolute path? that will depend on your usecase)
Use some pathname manipulation to point to test.py
Related
I have spent weeks creating a stand-alone application using py2app for my project but nothing works. Actually, I have created a setup.py file and add all packages I am using but the application from dist do not work but using terminal works. For example, I created an app with PyQt5 add all packages and it was working. But in my project, there are a lot of libs and another problem is that I need to add backend and some other modules to stand alone version.
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['__main__.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'site_packages': True, 'includes':['Brotli', 'certifi', 'chardet', 'click', 'dash', 'dash-core-components', 'dash-html-components', 'dash-renderer', 'dash-table', 'Flask', 'Flask-Compress', 'future', 'idna', 'itsdangerous', 'Jinja2', 'joblib', 'MarkupSafe', 'numpy', 'ordered-set', 'pandas', 'plotly', 'PyLaTeX', 'PyQt5', 'PyQt5-sip', 'python-dateutil', 'pytz', 'requests', 'retrying', 'scikit-learn', 'scipy', 'six', 'sklearn', 'threadpoolctl', 'urllib3', 'Werkzeug', 'xlrd', 'pandas._libs.tslibs.base', ]}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
the full project includes: main.py, dist backend, GUI, logs
what do I need to add to setup.py?
I built a keylogger in python and I used py2exe (version 0.13) to convert the python file to an exe. It worked perfectly, it included all the packages and everything.
I want my keylogger to come to mac also, so I tried to use py2app. I followed TheBlackBerryChannels tutorial. It was pretty good explaining everything but it didn't show how to install external packages that are installed from pip. Becuase I use the from pynput.keyboard import Key, Listener
import os
import datetime
from pathlib import Path
packages from pip.
In the full setup.py file this is what I have:
from setuptools import setup
APP = ['KeyLoggingMac.py']
OPTIONS = {
# 'iconfile':'logoapp.icns',
'argv_emulation': True,
'packages': ['pynput']
}
setup(
app=APP,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
What am I doing wrong? It doesn't include the pynput package, I figured that it would auto-include the os, datetime, and pathLib modules but why doesn't it include the pynput?
For simplicity sake in your main file import it like this:
from pynput import keyboard
Then in your setup file use 'includes' in OPTIONS, note that I also added the data file test.txt to write the key presses to a file:
from setuptools import setup
APP = ['TEST.py']
DATA_FILES = ['test.txt']
OPTIONS = {'includes': ['pynput']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Then from your venv run py2app with the terminal command:
python setup.py py2app
You can also use py2applet to generate setup.py files but I find it never works properly.
py2applet --make-setup FILENAME.py
You will also need to give the app permission to access your global keyboard events. This is done in Preferences > Security & Privacy > Privacy
Up to Mojave you want the Accessibility tab then add your app in there, on Catalina you want Input Monitoring.
This works for me.
I am working on packaging our Python app and Py2App on Mac is not including CefPython library which forms the basis of our app. From what I can see in the app contents, it includes the entire Python3 library, but not CEFPython. How can I add CefPython in setup.py? Currently, when I am generating the .app file and executing it, I get an error and Mac asks me if I want to open the console. I see nothing in install.log
setup.py :
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['Our_APP.py']
DATA_FILES = []
OPTIONS = {}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Updated script
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
from setuptools import setup
APP = ['20notes.py']
DATA_FILES = []
OPTIONS = {'packages':['cefpython3','objc']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app','cefpython3']
)
Updated error :
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app','cefpython3'],
TypeError: None is not a string
I have tried removing the comma, removing cefpython3 option, nothing works. Any idea. THank you.
Try adding 'cefpython3' package to OPTIONS:
OPTIONS = {
'packages' : ['cefpython3', 'objc'],
}
Also set this:
os.environ['MACOSX_DEPLOYMENT_TARGET'] = "10.9"
I want to make a game called "dodgeball". I have a main script, a setup.py script and an image called ball.bmp. In my setup.py script I have the following code:
from setuptools import setup
APP = ['dodgeball.py']
DATA_FILES = ["ball.bmp"]
OPTIONS = {'argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
When I run
sudo python setup.py py2app
Everything goes perfectly, except when I try to open Dodgeball.app it gives me this error (In a pop-up error window):
dodgeball Error
Open Console
Terminate
And it only works in alias mode:
sudo python setup.py py2app -A
How should I fix this?
I'm on Mac OS X El Capitan (10.11). I'm aware the new Mac update broke a few stuff.
import pygame._view worked.
:D
I am using buildout to create a local python environment, and then using the local python to create my app with py2app. But, when I go into the .app file, specifically into Contents/MacOS/, there is just a shortcut to the system python. I want py2app to somehow take the local python with it so that it only depends on itself, not on the system python.
So my question is: How can I fix this so that py2app will bundle my custom local version of python2.7 so that my app will be totally standalone, regardless of the local python version?
Please let me know if more information would be helpful.
My setup.py
from setuptools import setup
APP = ['main.py']
DATA_FILES = ['src/icon.xib']
OPTIONS = {
'argv_emulation': True,
'packages': [ 'requests' ],
'iconfile':'src/myApp.icns',
'plist': {'CFBundleShortVersionString':'0.1.0',
'LSUIElement': True
}
}
setup(
name='myApp',
package_dir = {'':'src'},
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Py2app will not include system files, such as the python installation in /System/Library/Frameworks, in your application bundle.
To create a bundle that also includes Python you need to install a separate version of Python (and all libraries that you use).
However, note that the app created with the system version of Python should work properly on machines with the same release of OSX, or a later release.