Pygame on Ubuntu Python 3

ぐ巨炮叔叔 提交于 2020-06-23 11:57:31

问题


I have searched everywhere. There is no answer for my specific problem! I have Ubuntu, I want to use pygame on Python 3. I installed the pygame package with

sudo apt-get python-pygame

but it just doesn't work when I type

import pygame    

Please help!


回答1:


You must install pip for python3

$ sudo apt install python3-pip

and then, with the pip installed, install pygame

$ pip3 install pygame



回答2:


The pygame package on Ubuntu is only for python 2.7, so it is impossible to import if you use python 3. If you want python 3.x support, you need to install pygame 1.9.2 which is located at https://bitbucket.org/pygame/pygame/downloads

If you have all the dependencies installed, it should be as simple as running setup.py




回答3:


Ubuntu 19.04 and later

To install python3-pygame in Ubuntu 19.04 and later open the terminal and type:

sudo apt install python3-pygame

Ubuntu 18.10

To install python3-pygame in Ubuntu 18.10 open the terminal and type:

sudo nano /etc/apt/sources.list  

Add this line to sources.list.

deb http://archive.ubuntu.com/ubuntu/ cosmic-proposed universe

Save sources.list with the keyboard combination Ctrl+O and press Enter and exit with Ctrl+X

Update the list of available software and install python3-pygame.

sudo apt update  
sudo apt install python3-pygame  

Ubuntu 18.04

Besides the obvious pip install solution in 18.04, the other alternative is to manually download the python3-pygame .deb file for 19.04 and install it with sudo apt ./python3-pygame_1.9.4.post1+dfsg-3_amd64.deb in 18.04. All the required dependencies are available in the 18.04 default repositories.



来源:https://stackoverflow.com/questions/26855293/pygame-on-ubuntu-python-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!