简体   繁体   English

Windows中的Pygame:ImportError:DLL加载失败

[英]Pygame in Windows: ImportError: DLL load failed

I just installed PyGame 1.9.1 (onto an existing python 2.6.4). 我刚刚安装了PyGame 1.9.1(在现有的python 2.6.4上)。 Python and it standard libraries work, however, there is a problem with python even being able to find the pygame modules (correctly). Python和它的标准库工作,然而,python甚至能够找到pygame模块(正确)有一个问题。

Traceback (most recent call last):
  File "C:\foo\bar\firstGame.py", line 2, in <module>
    import pygame
  File "C:\python264\lib\site-packages\pygame\__init__.py", line 95, in <module>
    from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.

Why is is this happening? 为什么会发生这种情况? Googling yielded the following responses, which I have tried to no avail: 谷歌搜索产生了以下回应,我试图无效:

Anyone out there fixed problems in win + pygame? 谁在那里修复了win + pygame的问题?

Thanks 谢谢


EDIT: more information added as requested: 编辑:根据要求添加更多信息:
- Windows version: Windows Vista (updated regularly) - Windows版本:Windows Vista(定期更新)
- Installer used: Windows MSI installers - 使用的安装程序:Windows MSI安装程序
- Installed for: All users - 已安装:所有用户
- Number of files in C:\\python264\\lib\\site-packages\\pygame : - C:\\python264\\lib\\site-packages\\pygame

  • DLL : 14 DLL:14
  • PYD : 34 PYD:34
  • PY : 19 PY:19
  • PYC : 1 PYC:1

Are you sure you have got pygame for Python 2.6? 你确定你有Python 2.6的pygame吗? The version for 2.5 wont work and produce this error msg, because the pyd file wont find the python 2.5 dll. 2.5的版本不会工作并产生这个错误消息,因为pyd文件不会找到python 2.5 dll。

I have faced this error on a Windows 64 bit. 我在Windows 64位上遇到此错误。 I have uninstalled my python 3.4.1 and I have installed: python-3.4.1.amd64.msi then pygame-1.9.2a0.win-amd64-py3.4.exe from link mentioned above. 我卸载了我的python 3.4.1并安装了:python-3.4.1.amd64.msi然后从上面提到的链接pygame-1.9.2a0.win-amd64-py3.4.exe。 And it worked. 它奏效了。

If you are running a 64 bit version of windows, with a 64 bit python, the default installers on the Pygame site don't seem to work. 如果您运行64位版本的Windows,使用64位python,Pygame站点上的默认安装程序似乎不起作用。

The pygame website led me there: There are some pre release binaries for 64bit windows, and for python 2.7 at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame pygame网站引导我到那里:64位窗口有一些预发布二进制文件,而http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame上有 python 2.7

This actually happened to my installation as well. 这实际上也发生在我的安装上。 I have Python 2.6.6 installed, but the installation did not include Pygame. 我安装了Python 2.6.6,但安装时没有包含Pygame。 I downloaded Pygame 1.9.1 with Python 2.6, and identified where the directory was located, the installation seemed to work. 我用Python 2.6下载了Pygame 1.9.1,并确定了目录所在的位置,安装似乎有效。 However, from the IDLE, I entered import pygame, and received the very error originally posted. 但是,从IDLE,我输入了导入pygame,并收到了最初发布的错误。

我有完全相同的错误,但我运行了一个小程序,我发现使用没有IDLE的pygame(通过保存代码,然后只需双击.py文件),它工作100%罚款。

To check exactly which DLL's are missing use the CMD like python console. 要确切地检查哪些DLL丢失,请使用CMD,如python控制台。 It will show a pop-up message indicating the missing DLL. 它将显示一条弹出消息,指示缺少的DLL。 Pygame works for me. Pygame适合我。

I had this error and after much digging discovered that the version of python interpreter MUST match the version of pygame installed. 我有这个错误,经过多次挖掘后发现python解释器的版本必须与安装的pygame版本相匹配。

If you have an erroneous combination, your best bet is to uninstall what you have via Start -> Control Panel -> Uninstall Programs. 如果您有错误的组合,最好的办法是通过开始 - >控制面板 - >卸载程序卸载您所拥有的内容。

A combination that works (Install in this order) - 有效的组合(按此顺序安装) -

Python 3.2.5 - Msi download this file for Windows Vista 32-bit- Python 3.2.5 - Msi下载此文件的Windows Vista 32位 -

www.python.org/download/releases/3.2.5/ - Windows x86 MSI Installer (3.2.5) <- This link, about halfway down the page www.python.org/download/releases/3.2.5/ - Windows x86 MSI安装程序(3.2.5)< - 此链接,大约在页面的一半

Pygame - pygame.org/download.shtml - Pygame - pygame.org/download.shtml -

pygame-1.9.2a0.win32-py3.2.msi <- This download link, bottom of the top list on the page. pygame-1.9.2a0.win32-py3.2.msi < - 此下载链接,页面顶部列表的底部。

Now you should be able to open IDLE (The default development environment) by finding the python folder from your start menu. 现在,您应该可以通过从开始菜单中找到python文件夹来打开IDLE(默认开发环境)。 Once it's open, type 'import pygame'. 一旦打开,输入'import pygame'。 Hopefully, you'll get no errors and pygame was imported properly. 希望你没有错误,pygame被正确导入。 I wish you luck with your programming endeavours. 祝你的编程工作顺利。祝你好运。

If you're dissatified with the IDLE environment and want to use another, I personally use the LiClipse IDE. 如果您对IDLE环境不满意并想使用其他环境,我个人使用LiClipse IDE。 I have no rep, but a google search should turn that one out ;) 我没有代表,但谷歌搜索应该把那个转出来;)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM