【问题标题】:Pygame already installed; however, python terminal says "No module named 'pygame' " (Ubuntu 20.04.1)Pygame 已经安装;但是,python终端说“没有名为'pygame'的模块”(Ubuntu 20.04.1)
【发布时间】:2021-11-01 10:31:46
【问题描述】:

我使用的是 Ubuntu 20.04.1 LTS。我已经使用 sudo apt-get install python-pygame 安装了 pygame。但是,当我使用 VS 代码运行代码时,python 终端会给出以下输出:

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

我尝试使用相同的命令重新安装 Pygame。这是输出:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-pygame is already the newest version (1.9.6+dfsg-2build1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

基本上,我已经安装了 pygame。那么您认为可能是什么原因呢?我的 Python 版本是 3.8.2。

提前致谢!

【问题讨论】:

  • 试试pip install pygame==2.0.0.dev10

标签: python python-3.x ubuntu installation pygame


【解决方案1】:

没有适用于 Python 3.8.2 的 pygame 1.9.6 发布版本。安装开发版本:

python3 -m pip install pygame==2.0.0.dev10

【讨论】:

  • 非常感谢!在在这里发布问题之前,我一直在寻找解决方案两个小时。
猜你喜欢
  • 1970-01-01
相关资源
最近更新 更多