2009-08-13 3 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

小学生エラー:

はPythonがあなたのstructモジュールを見つけた場所を確認するために、これを試してみてください。 cmd.exeを実行するとCWDがデスクトップにデフォルト設定されていました。私は以前に質問した質問から一時スクリプトを入手した場所です(http://stackoverflow.com/questions/1264833/python-class-factory-to-produce-simple-struct-like-classes)。私は検査を覚えています。ありがとうございました。 – kjfletch

+0

あなたはあなたのパッケージ階層に同じ名前の2つのパッケージを持っていません。私は "struct"パッケージを定義するのに無謀でしたが、NumPyと面白い競合がありました。本当に問題になるべきではないと思うかもしれませんが、そうです。 Python 3でさえ。 –

関連する問題