首页 > 解决方案 > 安装pygame时如何处理'ModuleNotFoundError:没有名为'pygame'的模块'?

问题描述

我使用 MacOS 上的终端通过键入以下命令安装 pygame:

python -m pip install --user pygame

随后,它给了我:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pygame
  Downloading pygame-1.9.6-cp27-cp27m-macosx_10_11_intel.whl (4.9 MB)
     |████████████████████████████████| 4.9 MB 2.0 MB/s 
Installing collected packages: pygame
Successfully installed pygame-1.9.6

当我去使用import pygame它时,它给了我,ModuleNotFoundError: No module named 'pygame'.

如何解决这个问题?

我还输入了“which -a python python3”,它给出了以下内容:

/usr/bin/python
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
/usr/local/bin/python3

标签: pygame

解决方案


推荐阅读