2009-08-13 10 views
4
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on 
win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import ctypes 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "C:\Python26\lib\ctypes\__init__.py", line 17, in <module> 
    from struct import calcsize as _calcsize 
ImportError: cannot import name calcsize 

>>> from ctypes import * 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "C:\Python26\lib\ctypes\__init__.py", line 17, in <module> 
    from struct import calcsize as _calcsize 
ImportError: cannot import name calcsize 
>>> 

답변

8

어딘가에 경로에 다른 struct.py가있는 것 같습니다.

>>> import inspect 
>>> import struct 
>>> inspect.getabsfile(struct) 
'c:\\python26\\lib\\struct.py' 
+0

모범생 오류 :

것은 파이썬이 구조체 모듈을 찾아 위치를 확인하기 위해보십시오. cmd.exe를 실행하면 CWD가 바탕 화면에 기본값으로 설정됩니다. 이전에 물어 본 질문에서 temp 스크립트가있는 곳 (http://stackoverflow.com/questions/1264833/python-class-factory-to-produce-simple-struct-like-classes). 나는 검열하는 것을 기억할 것이다. 고맙습니다. – kjfletch

+0

너는 너의 패키지 계층 구조 안에 같은 이름을 가진 두 개의 패키지가 없어야 해. 나는 "구조체"패키지를 정의 할만큼 충분히 무모했으며 NumPy와의 흥미로운 충돌이있었습니다. 정말로 문제는 아니어야한다고 생각할 수도 있지만 그렇습니다. 파이썬 3에서도. –