python开发应用程序错误_py2app应用程序出错

1586010002-jmsa.png

(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

import os

File "os.pyc", line 398, in

File "UserDict.pyc", line 83, in

File "_abcoll.pyc", line 11, in

File "/Users/Virendra/Desktop/dist/abc.app/Contents/Resources/abc.py", line 6, in

import psutil

File "build/bdist.macosx-10.8-x86_64/egg/psutil/__init__.py", line 54, in

File "build/bdist.macosx-10.8-x86_64/egg/psutil/_common.py", line 16, in

File "build/bdist.macosx-10.8-x86_64/egg/psutil/_compat.py", line 65, in

File "collections.pyc", line 6, in

AttributeError: 'module' object has no attribute '__all__'

logout

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'],

)

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()

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.

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值