首页 > 解决方案 > pygame 命令都不起作用;如,它说它们不存在

问题描述

我正在使用 VS 代码,我已经使用 pip 下载了 pygame,我可以看到它已经安装(版本 2.0.1)但是当我将它导入 python 文件并尝试用它做任何事情时,我被告知pygame 没有模块 _____。init QUIT任何按键命令都会发生这种情况。当我这样做时,import pygame; print(pygame)我得到:

pygame 2.0.1 (SDL 2.0.14, Python 3.9.1)
Hello from the pygame community. https://www.pygame.org/contribute.html
<module 'pygame' from 'C:\\Users\\James\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pygame\\__init__.py'>

当我这样做时,print(dir(pygame))我会得到一个非常长的命令列表,其中我之前所说的命令不起作用。我没有另一个名为 pygame 的文件夹/目录,我看到其他人认为这可能是问题所在。其他人说我需要对 VS 代码文件做一些事情,但我真的不明白他们在说什么。

另外我觉得值得注意的是,我之前在 VS 代码中使用过 pygame,但我删除并重新安装了 python,因为我安装了两个不同的版本,这只是破坏了事情。pygame 在我删除 python 之前停止工作,但在那种情况下,它no module called pygame说它不再这么说,但正如我之前所说,pygames 命令都不起作用

任何帮助将不胜感激

标签: pythonvisual-studiopippygame

解决方案


推荐阅读