[英]Pygame won't import to python
When i type import pygame, i get an error that reads:当我输入 import pygame 时,我收到一个错误消息:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
File "C:\Python27\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.
>>>
Does anybody know what this means?有人知道这是什么意思吗?
这意味着您需要查看 Dependency Walker 中的pygame\\base.pyd
并查看它找不到哪个 DLL。
I made this mistake too.我也犯过这个错误。 The problem is that you are using the Idle Shell to attempt to build a Python program.问题是您正在使用空闲 Shell 尝试构建 Python 程序。 Here is how I get out of the shell:这是我如何摆脱外壳:
Now you can import your modules and begin programming:现在您可以导入模块并开始编程:
import os, sys import pygame from pygame.locals import * [...]
This will give you the head start to work with pygame.这将为您提供使用 pygame 的良好开端。
This question at Game Developement (another Stack Exchange Site) should answer your question: Installing the right version of PyGame Game Developement(另一个 Stack Exchange 站点)上的这个问题应该可以回答您的问题: 安装正确版本的 PyGame
This user can't make Python to know that PyGame is there so he asks that question.该用户无法让 Python 知道 PyGame 存在,因此他提出了这个问题。 His question should be similar to yours, making it convinient for you.他的问题应该与你的相似,这样你就可以很方便地提出来。 I hope this helps you!我希望这可以帮助你!
在命令提示符下,如果您使用的是 Windows PC,请编写pip install pygame
如果您使用的是 Linux 或 MacOS,请编写pip3 install pygame
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.