简体   繁体   English

Python在Mac上找不到Pygame模块

[英]Python can't find Pygame module on Mac

Using home-brew I have installed pygame as homebrew says this 使用home-brew我已经安装pygame,因为homebrew说

"Requirement already satisfied: pygame in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.9.1release)" “已经满足要求:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages(1.9.1release)中的pygame”

but when I run idle3 and import pygame, python says this 但是当我运行idle3并导入pygame时,python会这样说

">>> import pygame
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import pygame
ModuleNotFoundError: No module named 'pygame'"

Add /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages to your system path so Python knows to search here for libraries. /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages添加到您的系统路径中,以便Python知道在这里搜索库。

Here's a tutorial here 这里有一个教程在这里

When running Idle3, you are likely not invoking your Python 2.7 interpreter for which you've installed pygame . 运行Idle3时,您可能不会调用已为其安装pygame Python 2.7解释器。

Does it work if you run python2.7 from the terminal and then import pygame there? 如果您从终端运行python2.7然后在其中import pygame ,是否可以正常工作?

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

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