PyCharm 不会导入 PyGame [英] PyCharm won't import PyGame

查看:64
本文介绍了PyCharm 不会导入 PyGame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 python 还很陌生,决定尝试 PyGame 却发现它无法导入.

I'm fairly new to python and decided to try PyGame only to find it won't import.

line 1, in <module>
    import pygame
ModuleNotFoundError: No module named 'pygame'

我在 Windows 10 上,我使用 PyCharm Build #PE-182.3684.126,我通过 CMD pip 安装它.到目前为止,我已经重新安装了两次 PyGame,但它仍然无法正常工作.如果有人可以提供建议,将不胜感激.

I am on windows 10, I am using PyCharm Build #PE-182.3684.126, and I pip installed it through CMD. I have reinstalled PyGame twice so far and it still won't work. If anyone can provide advice it would be greatly appreciated.

推荐答案

打开您的 PyCharm 项目.转到 File->Settings->Project->Project Interpreter.您正在使用的当前 python 环境中将有一个所有已安装模块的列表.如果 pygame 未在此处列出,则说明尚未为该 PyCharm 项目安装它(使用该 python 环境).

Open your PyCharm project. Go to File->Settings->Project->Project Interpreter. There will be a list of all installed modules on the current python environment you are using. If pygame is not listed there, it hasn't been installed for that PyCharm project (using that python environment).

您可以使用 PyCharm 界面安装它,只需点击 + 符号并搜索 pygame 并点击安装.

You can install it by using PyCharm interface, just click on the + sign and search for pygame and click install.

这篇关于PyCharm 不会导入 PyGame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆