简体   繁体   English

导入“pygame”无法解决

[英]Import "pygame" could not be resolved

I installed pygame using the pip in command prompt but it still shows an error.我在命令提示符下使用 pip 安装了 pygame 但它仍然显示错误。 I have already attempted changing the path so pip could properly be accessed and using the line "pygame.init()" but the error still appears.我已经尝试更改路径,以便可以正确访问 pip 并使用“pygame.init()”行,但错误仍然出现。

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

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.顺便说一下,如果它仍然无法正常工作,您可以尝试使用 Pycharm。如果您不能这样做,您可以尝试使用 replit 并下载 pygame package,然后使用 Github 将其导出。

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

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