am getting an error about calling a method from a group of python files bundled with py2app
(1) I have read various info on the py2app importing large directories or package groups etc. but it seems to have problems interacting with said files. I hard coded each file to be included via my setup, however it still says it can't call a function from my file 'random.py' which generates its own script to run through 'happy.py' <- it runs perfectly on its own and all the dependencies are correct (imports from etc.)
(2) to make this even more complex the app is run 100% via terminal so I'm not sure if I will just need to send people the .exe in order to use since I assume py2app will just run the script without any options for user input..
SETUP FILE
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['happy.py']
DATA_FILES = ['happy.pyc',
'random.py',
'random.pyc',
'happy.py',
'screener.py',
'__init__.py',
'screener.pyc',
'setup.py']
OPTIONS = {'argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
py_modules=['random', 'screener', '__init__','happy',],
setup_requires=['py2app'],
)
ERROR OUT(given by .exe inside of .app, since .app runs a console error 255 with 0 info)
| | _____ _____| | / |
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: | |/ _ \ \ / / _ \ | | |
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: | | __/\ V / __/ | | |
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: |_|\___| \_/ \___|_| |_|
Sep 9 04:39:12 softroot.local happy[39888] <Notice>:
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: Traceback (most recent call last):
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: File "/Users/random/Desktop/bla/dist/happy.app/Contents/Resources/__boot__.py", line 373, in <module>
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: _run()
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: File "/Users/random/Desktop/bla/dist/happy.app/Contents/Resources/__boot__.py", line 358, in _run
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: exec(compile(source, path, 'exec'), globals(), globals())
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: File "/Users/random/Desktop/bla/dist/happy.app/Contents/Resources/happy.py", line 275, in <module>
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: print testone()
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: File "/Users/random/Desktop/bla/dist/happy.app/Contents/Resources/happy.py", line 52, in testone
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: from random import function
Sep 9 04:39:12 softroot.local happy[39888] <Notice>: ImportError: cannot import name function
Is random.py
a custom script written by you, or is it the module from Pyhton standard?
Have you tried to copy the random.py
from the resulting application package, import random
, check random.__file__
to make sure it is this one, and the try to execute the line with problems from random import function
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.