牛骨文教育服务平台(让学习变的简单)
博文笔记

python 2.7.12报ImportError: No module named _socket

创建时间:2017-09-28 投稿人: 浏览次数:189

最近在做一个smpp的python库,由于RF依赖Python2,于是从python3切换到python2,运行代码提示:

File "C:Python27libsocket.py", line 47, in <module>

    import _socket

ImportError: No module named _socket

百度了一下,在https://stackoverflow.com/questions/24173487/import-socket-import-error-dll-load-failed 这个页面看到了解决方法:重新安装python 2.7.12,有人说是32位和64位操作系统的问题,下面是这些人的解释:

Attempting to install python 2.7.12 again, the installer recognized the existing installation and offered me change/repair/uninstall options.
Update: In retrospective, the reason might have been, that I unintentionally mixed a 32-bit installation with a 64-bit update (or vice versa). Python doesn"t seem to install into different directories or use different DLL-names. The installer doesn"t warn you either. So after the update, your DLLs are a unhealthy mix of 32 and 64-bit variants.



I would suggest getting, PyWin32 or either PyWin64, depending on your System architecture. If your system is x86, get PyWin32, otherwise get PyWin64 if your system is x64. I have similar problems myself and getting PyWin32 helped me out in fixing these problems.


我的电脑是64位的,于是去https://www.python.org/downloads/release/python-2712/下载了64位的安装包,重新安装了python 2.7.12,问题解决。

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。