[英]Unable to import Pygame after pip install Pygame
我试图在 Python 中制作一个简单的蛇游戏,所以我使用 pip 安装 Pygame 安装 ZC1687207793A103。 安装成功后,我尝试导入 Pygame 但出现此错误:
ModuleNotFoundError:没有名为“pygame”的模块
我是 python 的新手,所以我真的被卡住了。 我通过代码导入了模块。
import pygame
如果您在 windows:
打开 cmd 然后输入:
cd\
cd /d C:\Windows
cd /d C:\Users\username\AppData\Local\Programs\Python\Python37\Scripts
然后输入命令:
pip install pygame
如果你在 Mac 上:试试python -m pip install pygame
如果您使用的是 linux:
pip install pygame
如果您使用 pycharm 或 sublime,请确保将 pygame 安装到项目的“venv”文件夹中。 如果您使用的是 IDLE,请按住 windows+R 打开命令提示符,然后搜索 cmd,或者如果您在 mac 上:cmd+space 并搜索终端。 then type pip install pygame
for windows, and python -m install pygame
for mac.
If you are using Pycharm and your stuck goto settings and then proceed to python interpreter you will see a page listing installed modules in your Pycharm project click the small plus sign and search for pygame after that click Install Package. 如果您仍然看到错误消息,请重复这些步骤,如果这不起作用,请尝试使用 Internet 连接。 我不擅长命令提示符,但有办法。 注意:我还是这个领域的新手,所以我不知道你是否会认为我的想法有用谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.