简体   繁体   English

为什么 VSC 说 Import "pygame" 无法解决

[英]Why does VSC say Import "pygame" could not be resolved

I am using pygame for the first time but when i try to import it to VSC it says Import "pygame" could not be resolved does anyone know why this is and how to resolve it?我第一次使用 pygame 但是当我尝试将它导入 VSC 时它说 Import "pygame" 无法解决有谁知道这是为什么以及如何解决它?

import pygame
import sys
import random 

First, make sure that when you downloaded python, you enabled "Add python to PATH".首先,确保在下载 python 时启用了“将 python 添加到 PATH”。 If not, please reinstall it, but make sure to enable "Add python to PATH" this time.如果没有,请重新安装,但这次一定要启用“Add python to PATH”。 Once installed, to test if you installed it without an error, open the command prompt by searching "cmd" in the search bar.安装后,要测试是否安装没有错误,请通过在搜索栏中搜索“cmd”打开命令提示符。 Then, write "python" and hit eneter.然后,写“python”并点击 eneter。 If it doesn't return an error, try:如果它没有返回错误,请尝试:

pip install pygame pip 安装 pygame

If that doesn't work:如果这不起作用:

pip3 install pygame pip3 安装 pygame

Past that, if that doesn't work, that might mean that you installed python incorrectly, once again.过去,如果这不起作用,那可能意味着您再次错误地安装了 python。 Good luck with the code you're writing.祝您编写的代码好运。

You need to insall PyGame first您需要先安装 PyGame

After opening VSC go to the terminal tab Ctrl + ` and type打开 VSC go 到终端选项卡Ctrl + `并键入

pip install pygame

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

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