简体   繁体   English

为什么导入ctypes会引发ImportError?

[英]Why does import of ctypes raise ImportError?

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

It seems you have another struct.py in your path somewhere. 看来你的路径中有另一个struct.py。

Try this to see where python finds your struct module: 试试看python找到你的struct模块的地方:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么__future__ import *引发错误? - Why does from __future__ import * raise an error? 有人可以解释为什么这个导入不会引发错误吗? - can someone explain why this import does not raise an error? ctypes vs _ctypes - 为什么后者存在? - ctypes vs _ctypes - why does the latter exist? python:GeoDjango:Eclipse:在单元测试期间,引发ImportError,“无法导入设置&#39;%s&#39;(是否在sys.path上?是否有语法错误?) - python: GeoDjango: Eclipse: During Unit Test, raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?) 为什么ctypes WriteProcessMemory()失败? - Why does ctypes WriteProcessMemory() fail? 哪个是处理ImportError的更好方法-引发错误或导入链? - Which is the better way to handle ImportError - Raise error or import chain? 当我从并发导入时,它给了我ImportError.futures import ThreadPoolExecutor`。 有人知道为什么吗? - It gives me ImportError when I import `from concurrent.futures import ThreadPoolExecutor`. Does anyone know why? 为什么python不会引发NameError - Why python does not raise NameError Django为什么会引发“ KeyError”? - Why does Django raise “KeyError”? 为什么 pyinstall 会引发导入错误。 python 代码本身运行良好吗? - Why does pyinstall raise import error. The python code runs fine by itself?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM