简体   繁体   English

即使应该安装 pygame 也无法导入

[英]Unable to import pygame even though it should be installed

So I'm trying to install pygame using pip and then I'm trying to import pygame(using vscode by the way) but when I try to import it I get:所以我尝试使用 pip 安装 pygame 然后我尝试导入 pygame(顺便使用 vscode)但是当我尝试导入它时我得到:

ModuleNotFoundError: No module named 'pygame'

Doing python --version in the vscode terminal outputs that my python version is Python 3.10.6 and when I do pip list it does show that pygame 2.1.2 is indeed installed. Doing python --version in the vscode terminal outputs that my python version is Python 3.10.6 and when I do pip list it does show that pygame 2.1.2 is indeed installed. What am I doing wrong here?我在这里做错了什么?

You can install a module for a specific python version: python3.10.6 -m pip install pygame您可以为特定的 python 版本安装模块: python3.10.6 -m pip install pygame

But this command will probably throw an error, because pygame doesn't support python versions above 3.9.5 yet, so you have to use an older version or wait for a the next pygame release.但是这个命令可能会抛出一个错误,因为 pygame 还不支持 python 3.9.5 以上的版本,所以你必须使用旧版本或等待下一个 Z9CC57E6C320F1D54EEA8690342DA30A 版本。

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

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