导入“ pygame”无法解决
我在命令提示符下使用 pip 安装了 pygame,但它仍然显示错误。我已经尝试更改路径,以便可以正确访问 pip 并使用“pygame.init()”行,但错误仍然出现。
这是代码:
import pygame, sys
pygame.init()
w, h = 600, 600
r = (255, 0, 0)
s = pygame.display.set_mode( (w, h) )
s.fill(r)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
pygame.display.update()
I installed pygame using the pip in command prompt but it still shows an error. I have already attempted changing the path so pip could properly be accessed and using the line "pygame.init()" but the error still appears.
Here's the code:
import pygame, sys
pygame.init()
w, h = 600, 600
r = (255, 0, 0)
s = pygame.display.set_mode( (w, h) )
s.fill(r)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
pygame.display.update()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
顺便说一句,如果它仍然不起作用,您可以尝试使用 Pycharm。如果你做不到,你可以尝试使用 replit 并下载 pygame 包,然后使用 Github 导出它。
by the way if it still isn't working you could try using Pycharm. If you can't do that you could try using replit and downloading the pygame package, then exporting it with Github.