Python Py2app打包目录

时间:2014-09-09 17:43:29

标签: python python-2.7 packaging python-import py2app

从使用py2app

捆绑的一组python文件调用方法时收到错误

(1)我已经阅读了有关py2app导入大型目录或包组等的各种信息,但似乎与所述文件交互时出现问题。我通过我的设置对每个文件进行硬编码,但它仍然说它不能从我的文件'random.py'中调用一个函数,该文件生成自己的脚本以运行'happy.py'< - 它运行完美本身和所有依赖都是正确的(从等等进口)

(2)为了使这个更复杂,应用程序通过终端100%运行所以我不确定我是否只需要发送人员.exe以便使用,因为我假设py2app将只运行脚本没有任何用户输入选项..

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

1 个答案:

答案 0 :(得分:0)

random.py是您编写的自定义脚本,还是来自Pyhton标准的模块?

您是否尝试从生成的应用程序包random.py复制import random,检查random.__file__以确保它是这个,并尝试执行带有问题的行{ {1}}?