繁体   English   中英

Pygame 无法在 VS Code 上运行,即使它已安装

[英]Pygame not working on VS Code even though it is installed

我正在努力让 pygame 在 VS Code 上工作。 The only thing that seems to be amiss is that these are different versions and they are in different folders: PS C:\Users\rebec\My Drive\VS Code\Python Config> python --version Python 3.9.11 PS C:\ Users\rebec\My Drive\VS Code\Python Config> pip --version pip 22.1.2 from C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\站点包\pip (python 3.10)

我已经尝试卸载和安装 pygame。 我认为这是文件配置的问题,但我只是不知道如何修复它。 在此先感谢您的帮助

您的计算机上安装了两个版本的 python。 一个是 3.9.11,另一个是 3.10。 您为 python 3.10 安装了 pygame,并尝试使用 python 3.9.11 运行它。

如果你想使用全局解释器(python 3.10,你安装 pygame 的那个)运行你的游戏,你需要在 VSCode 中切换你的解释器

  1. 按 Ctrl+Shift+P 打开命令调色板。
  2. 打开Python: Select interpreter
  3. 将您的解释器设置为全局解释器。

您可能还需要考虑使用虚拟环境来避免将来出现此类问题:

Each virtual environment has its own Python binary (allowing creation of environments with various Python versions) and can have its own independent set of installed Python packages in its site directories, but shares the standard library with the base installed Python.

暂无
暂无

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

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