python rumps在OS X 10.10上无法工作 - AttributeError: 'module'对象没有属性'App

0 投票
1 回答
622 浏览
提问于 2025-04-30 08:35

我正在尝试运行一些来自 http://rumps.readthedocs.org/en/latest/examples.html 的示例,这些示例是关于非常简单的 Mac OS X Python 状态栏应用的。但是在导入 rumps 时,我遇到了一个错误:AttributeError: 'module' object has no attribute 'App'

Mac-28cfe915100b-2:Desktop andi$ pip install rumps
Requirement already satisfied (use --upgrade to upgrade): rumps in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): pyobjc-core in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC (from rumps)
Cleaning up...
Mac-28cfe915100b-2:Desktop andi$ python
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rumps
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rumps.py", line 4, in <module>
    class AwesomeStatusBarApp(rumps.App):
AttributeError: 'module' object has no attribute 'App'
暂无标签

1 个回答

0

这和rumps没有关系,而是因为你把示例代码复制到了一个叫“rumps.py”的文件里。只要你从一个同名的文件里导入其他模块,就会出现同样的错误。

$ echo "import math; math.sqrt(42)" > math.py
$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "math.py", line 1, in <module>
    import math; math.sqrt(42)
AttributeError: 'module' object has no attribute 'sqrt'

撰写回答