py2app应用程序出错 [英] Error in py2app application

查看:1024
本文介绍了py2app应用程序出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(OSX = Mountain lion)我在/ dist中的应用程序抛出错误:

(OSX = Mountain lion) My app in /dist throws the error:

Last login: Wed Aug 28 11:21:29 on ttys001
-MacBook-Pro:~ $ /Users/Desktop/dist/abc.app/Contents/MacOS/abc ; exit;
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/py2app/apptemplate/lib/site.py", line 20, in   <module>
import os
 File "os.pyc", line 398, in <module>
 File "UserDict.pyc", line 83, in <module>
 File "_abcoll.pyc", line 11, in <module>
 File "/Users/Virendra/Desktop/dist/abc.app/Contents/Resources/abc.py", line 6, in <module>
import psutil 
 File "build/bdist.macosx-10.8-x86_64/egg/psutil/__init__.py", line 54, in <module>
 File "build/bdist.macosx-10.8-x86_64/egg/psutil/_common.py", line 16, in <module>
 File "build/bdist.macosx-10.8-x86_64/egg/psutil/_compat.py", line 65, in <module>
 File "collections.pyc", line 6, in <module>
 AttributeError: 'module' object has no attribute '__all__'
 logout

我的setup.py(即使没有 - 'import os'也是同样的错误)看起来像:

My setup.py (same error even without the - 'import os') looks like:

"""
This is a setup.py script generated by py2applet

Usage:
python setup.py py2app

from setuptools import setup

APP = ['abc.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'includes': ['psutil', 'time', 'socket', 'os']}

setup(
   app=APP,
   data_files=DATA_FILES,
   options={'py2app': OPTIONS},
   setup_requires=['py2app'],
)

有问题的脚本abc.py:

And the scrip abc.py in question:

    from psutil import cpu_times_percent 
    import socket
    import time


    serverHost = "localhost"
    thisClient = socket.gethostname()
    cpuStats = psutil.cpu_times_percent()
    print cpuStats
    currentTime = int(time.time())
    s = socket.socket()
    s.connect((serverHost,8080))
    command = 'put cpu.usr ' + str(currentTime) + " " + str(cpuStats[0]) + " host="+ thisClient+ "\n" 
    s.sendall(command)
    command = 'put cpu.nice ' + str(currentTime) + " " + str(cpuStats[1]) +" host="+ thisClient+ "\n"
    s.sendall(command)
    command = 'put cpu.sys ' + str(currentTime) + " " + str(cpuStats[2]) + " host="+ thisClient+ "\n"
    s.sendall(command)
    command = 'put cpu.idle ' + str(currentTime) + " " + str(cpuStats[3]) + " host="+     thisClient+ "\n"
    s.sendall(command)
    s.close()

最初是'导入psutil',我将其改为'来自psutil ...',如上所述。这里包括'import os ...'。但是所有组合都会产生同样的错误。在其他地方,我已经看到'import psutil'作为标准导入,这也不例外。还有什么错误 AttributeError:'module'对象没有属性'__all __'是什么意思? Thx。

Initially it was 'import psutil' which I changed to the 'from psutil...' as above. Included the 'import os...' here. But all combinations throw the same error. Elsewhere, I have seen 'import psutil' as a standard import and this is no different. What else could the error AttributeError: 'module' object has no attribute '__all__' mean? Thx.

推荐答案

您的脚本文件 abc.py 与冲突 Python标准库抽象基类模块 abc 。最简单的解决方案应该是将文件名更改为其他名称。

Your script file, abc.py, conflicts with the Python standard library Abstract Base Class module, abc. The simplest solution should be to just change the name of your file to something else.

这篇关于py2app应用程序出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆