简体   繁体   English

'ImportError: No module named pygame' 在已经安装 pygame 之后

[英]'ImportError: No module named pygame' after installing pygame already

I usually work with Unity, but today I decided to give pygame another go to improve my python skills.我通常使用 Unity 工作,但今天我决定给 pygame 另一个 go 来提高我的 python 技能。 In MacOSX terminal, I installed pygame like so: $ pip3 install pygame , and everything works.在 MacOSX 终端中,我像这样安装了pygame$ pip3 install pygame ,一切正常。 Then I decided to test its functionality by quickly hopping into python in terminal: $ python3 .然后我决定通过在终端中快速跳转到 python 来测试它的功能: $ python3 Then imported it:然后导入它:

>>> import pygame

everything worked.一切正常。 Then, in my project, I was importing some of the standard modules I knew I would need:然后,在我的项目中,我导入了一些我知道我需要的标准模块:

import time
import pygame
import random
import os

and it said, after running, that the module pygame was not installed.它说,运行后,未安装模块pygame Since I'm on Mac, python 2.7 is pre-installed and I might have installed pygame in the 2.7 directory, but I checked it all out and nothing seems to be wrong.由于我在Mac上,预装了python 2.7,我可能已经在2.7目录下安装了pygame ,但我都检查过了,似乎没有错。 Please help me install pygame!请帮我安装pygame! Thanks谢谢

If yours is a recent version of MAC OS X try this:如果您使用的是最新版本的 MAC OS X,请尝试以下操作:

python3 -m pip install -U pygame --user

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

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