Python 试图理解一个错误-wintypes.Structure

Python 试图理解一个错误-wintypes.Structure,python,spyder,Python,Spyder,我需要帮助才能弄明白这件事。 昨天,我在我的Win7 64位笔记本电脑上安装了Spyder 2.3的测试版,以与Anaconda Python 3.3配合使用。 打开一个内部控制台窗口,我注意到每秒都会触发一个错误 Traceback (most recent call last): File "C:\Miniconda3\lib\site-packages\spyderlib\widgets\status.py", line 80, in update_label self.label.s

我需要帮助才能弄明白这件事。
昨天,我在我的Win7 64位笔记本电脑上安装了Spyder 2.3的测试版,以与Anaconda Python 3.3配合使用。 打开一个内部控制台窗口,我注意到每秒都会触发一个错误

Traceback (most recent call last):
File "C:\Miniconda3\lib\site-packages\spyderlib\widgets\status.py", line 80, in update_label
  self.label.setText('%d %%' % self.get_value())
File "C:\Miniconda3\lib\site-packages\spyderlib\widgets\status.py", line 93, in get_value
  return memory_usage()
File "C:\Miniconda3\lib\site-packages\spyderlib\utils\system.py", line 20, in windows_memory_usage
  class MemoryStatus(wintypes.Structure):
AttributeError: 'module' object has no attribute 'Structure'
这似乎是因为在未安装
psutil
时尝试使用“
wintype.Structure
”,而我在中看不到结构类(或模块)之类的东西。。。甚至
c_uint64
也不在
wintypes

我用简单的方法解决了这个问题——我刚刚安装了
psutil
,就完成了。但事实上,有几个脚本似乎使用了
wintypes.Structure
(请参阅)。我真的不明白。。。那么我错过了什么呢?

谢谢

我正在编辑我的答案

这里的问题似乎是Python 2.7版本的wintypes.py(来自ctypes 1.1.0包)以
从ctypes导入*

Python 3.3 ctypes 1.1.0包中的wintypes.py使用:
导入ctypes

因此基本上
wintypes.Structure
.c_uint64
.sizeof
.byref
都来自
ctypes
。它们在
wintypes
中不会被更改-至少在1.1.0版本之前不会被更改。因此,对Spyder(2.3.0beta3)的
status.py
的这一更改应该使它在Python 2.7和Python 3.3中都能正常工作:

def windows_memory_usage():
    """Return physical memory usage (float)
    Works on Windows platforms only"""
    from ctypes import windll, Structure, c_uint64, sizeof, byref
    from ctypes.wintypes import DWORD
    class MemoryStatus(Structure):
        _fields_ = [('dwLength', DWORD),
                    ('dwMemoryLoad',DWORD),
                    ('ullTotalPhys', c_uint64),
                    ('ullAvailPhys', c_uint64),
                    ('ullTotalPageFile', c_uint64),
                    ('ullAvailPageFile', c_uint64),
                    ('ullTotalVirtual', c_uint64),
                    ('ullAvailVirtual', c_uint64),
                    ('ullAvailExtendedVirtual', c_uint64),]
    memorystatus = MemoryStatus()
    # MSDN documetation states that dwLength must be set to MemoryStatus
    # size before calling GlobalMemoryStatusEx
    # http://msdn.microsoft.com/en-us/library/aa366770(v=vs.85)
    memorystatus.dwLength = sizeof(memorystatus)
    windll.kernel32.GlobalMemoryStatusEx(byref(memorystatus))
    return float(memorystatus.dwMemoryLoad)

尝试:从wintypes导入结构即使我将cwd设置为
ctypes
,这样我就可以直接从wintypes导入结构
,我得到:
ImportError:无法导入名称结构
名称“结构”未定义
即使这样导入:从ctypes导入wintypes?或者从ctypes.wintypes导入结构?哦,但是有一个
wintypes.ctypes.Structure