Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pygame 1.9.6已安装,但接收ModuleNotFoundError_Python_Ubuntu_Pygame - Fatal编程技术网

Python Pygame 1.9.6已安装,但接收ModuleNotFoundError

Python Pygame 1.9.6已安装,但接收ModuleNotFoundError,python,ubuntu,pygame,Python,Ubuntu,Pygame,我在Ubuntu 20.04上。今天,我按照上的说明安装了Python 3.8.3和Pygame 1.9.6。当我试图通过在终端中键入以下内容来测试它是否有效时: python3 -m pygame.examples.aliens 我得到了这个结果: /usr/local/bin/python3: Error while finding module specification for 'pygame.examples.aliens' (ModuleNotFoundError: No modu

我在Ubuntu 20.04上。今天,我按照上的说明安装了Python 3.8.3和Pygame 1.9.6。当我试图通过在终端中键入以下内容来测试它是否有效时:

python3 -m pygame.examples.aliens
我得到了这个结果:

/usr/local/bin/python3: Error while finding module specification for 'pygame.examples.aliens' (ModuleNotFoundError: No module named 'pygame')
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pygame is already the newest version (1.9.6+dfsg-2build1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
但是,当尝试通过输入以下内容重新安装pygame时:

sudo apt-get install python3-pygame
我得到这个结果:

/usr/local/bin/python3: Error while finding module specification for 'pygame.examples.aliens' (ModuleNotFoundError: No module named 'pygame')
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pygame is already the newest version (1.9.6+dfsg-2build1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

所以我知道它已经安装并且是最新的,但是有些东西并没有在两者之间建立联系。如何使Pygame工作?

这是否回答了您的问题?请尝试
pip install pygame
将pygame软件包添加到python软件包中。我也有同样的问题。我会问这个问题,看看是否有人回答。@B问题是pygame没有在Ubuntu上安装pip。当我运行命令“pip install pygame”时,它说“找不到命令'pip',但有18个类似的命令。”
sudo apt install python3 pip
然后
pip3 install pygame
这是否回答了您的问题?请尝试
pip install pygame
将pygame软件包添加到python软件包中。我也有同样的问题。我会问这个问题,看看是否有人回答。@B问题是pygame没有在Ubuntu上安装pip。当我运行命令“pip install pygame”时,它说“找不到命令'pip',但有18个类似的命令。”
sudo apt install python3 pip
then
pip3 install pygame