pygame在atom上可以运行,在vscode上不行

img

img

代码为


import sys
import pygame
def run_game():
    pygame.init()
    screen = pygame.display.set_mode((1200,800))
    pygame.display.set_caption("Alien Invasion")

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

        pygame.display.flip()
run_game()

在vs code中的setting. json中设置了Auto Complete:Extra Path 路径,仍然不行。
请帮忙解答一下,万分感谢!!

你没有安装pygame这个模块,估计是环境的问题。
你注意一下VS Code的右下角有一个环境选择

img


在这里选择你对应的环境就好。

如果不清楚Atom是什么环境
你在里面输入python,然后VS Code看着对应选择即可