You are not logged in.

#1 2013-05-04 21:37:41

ampe
Member
Registered: 2012-07-31
Posts: 27

[solved]using Pygame with Python 3

Is it possible? I've recently been following a book "Invent Your Own Computer Games With Python" and I just got to the part where we have to actually install Pygame (2/3 into the book), the only available version in the repos is for Python 2, the book uses Python 3. On the Pygame website there is a version available for download for python 2 or Python 3 for windows, but that doesn't seem to be the case for Linux. Even when I try to compile from (the only) source I get "NameError: name 'raw_input' is not defined" when trying to compile using python 3 so I assume the the installation scripts are written in Python 2 for python 2? Is there anyway to use Pygame with Python 3 under Linux? I was really looking forward to continuing with this book and finally advancing to 2D game creation. I've searched the AUR and the wiki for Pygame on Python 3 but am I safe to say it doesn't exist for Linux?

Last edited by ampe (2013-05-04 22:40:22)

Offline

#2 2013-05-04 21:42:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved]using Pygame with Python 3

What about https://aur.archlinux.org/packages/python3-pygame2/ ? It's not pygame but pygame2, but it's mentioned on the pygame website http://www.pygame.org/wiki/FrequentlyAskedQuestions?

Does Pygame work with Python 3?
Mostly yes. Only the scrap, _movie, surfarray for Numeric, and threads modules have not been ported. The Pygame alternative, pgreloaded (Pygame Reloaded), also supports Python 3.


Edit: There's also pygame for python (i.e. python 3) https://aur.archlinux.org/packages/python-pygame-hg/

Last edited by karol (2013-05-04 21:49:26)

Offline

#3 2013-05-04 21:58:34

ampe
Member
Registered: 2012-07-31
Posts: 27

Re: [solved]using Pygame with Python 3

karol wrote:

What about https://aur.archlinux.org/packages/python3-pygame2/ ? It's not pygame but pygame2, but it's mentioned on the pygame website http://www.pygame.org/wiki/FrequentlyAs … Python%203?

Does Pygame work with Python 3?
Mostly yes. Only the scrap, _movie, surfarray for Numeric, and threads modules have not been ported. The Pygame alternative, pgreloaded (Pygame Reloaded), also supports Python 3.


Edit: There's also pygame for python (i.e. python 3) https://aur.archlinux.org/packages/python-pygame-hg/


Okay, thanks for the info. I came across your first AUR link earlier but it is actually 'pgreloaded', and the second AUR link is correct (I guess) but is outdated and missing a source for me to do it myself. I'd prefer to use the official pygame files but they don't seem to exist or are being very elusive for some reason and pgreloaded seems like the only way to do it.

Does anyone have further information about this?

Offline

#4 2013-05-04 22:16:36

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved]using Pygame with Python 3

AUR packages fetch the files from pygame mercurial repo. You can (and should) read the PKGBUILDs to make sure: https://aur.archlinux.org/packages/py/p … g/PKGBUILD :

_hgroot=https://bitbucket.org/pygame
_hgrepo=pygame

https://bitbucket.org/pygame/pygame

Offline

#5 2013-05-04 22:39:12

ampe
Member
Registered: 2012-07-31
Posts: 27

Re: [solved]using Pygame with Python 3

SOLUTION:

1. Get the PKGBUILD: https://aur.archlinux.org/packages/py/p … g/PKGBUILD

2. pacman -S mercurial

3. Edit the PKGBUILD like so:

Replacing:
hg clone "$_hgroot" "$_hgrepo"

with:
hg clone "$_hgroot"/"$_hgrepo"

4. Run the PKGBUILD like normal.

Now Python 3 will import pygame. Thanks karol, and people in the AUR. smile

Offline

#6 2013-05-04 22:45:58

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved]using Pygame with Python 3

You're welcome :-)

I forgot to write that I think the PKGBUILD isn't outdated, it's simply a bit broken, so you have to read the comments on the AUR page and edit the PKGBUILD accordingly - it has been marked as outdated on 2013-04-12, the same date as the comment you quoted. I see you figured it out yourself :-)
The sources are fetched from the mercurial repo, so they're always up to date, unlike e.g. a versioned tarball (unless it's a nightly build).

Offline

#7 2017-05-05 19:21:38

astrolavos
Member
Registered: 2017-05-05
Posts: 3

Re: [solved]using Pygame with Python 3

ampe wrote:

SOLUTION:

1. Get the PKGBUILD: https://aur.archlinux.org/packages/py/p … g/PKGBUILD

2. pacman -S mercurial

3. Edit the PKGBUILD like so:

Replacing:
hg clone "$_hgroot" "$_hgrepo"

with:
hg clone "$_hgroot"/"$_hgrepo"

4. Run the PKGBUILD like normal.

Now Python 3 will import pygame. Thanks karol, and people in the AUR. smile

I try to folow the solution of this post but the "Get the PKGBUILD: https://aur.archlinux.org/packages/py/p … g/PKGBUILD " the link don't work!
I try to import pygame in python 3 but always say to me:

>>> import pygame
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import pygame
ModuleNotFoundError: No module named 'pygame'
>>>
I have 64bit
Please any help?

Offline

#8 2017-05-05 20:00:23

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,783
Website

Re: [solved]using Pygame with Python 3

What a suprise, things have changed in the past four years..

Please do not necrobump.

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB