Can't install pygame_sdl2

2019-08-18 05:30发布

问题:

I'm creating a tower defense game using python and pygame. I would like to add this one on the Google Play Store, but I need to create an apk file.

I'm following a tutorial on GitHub: https://github.com/renpytom/rapt-pygame-example. I follow all the instructions but can't install pygame_sdl2. I use the command prompt, and use $ python setup.py install in the appropriate directory.

But it gave me this error :

C:\Users\gomes\Downloads\pygame_sdl2-master>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 59, in <module>
    parse_cflags([ "sh", "-c", "sdl2-config --cflags" ])
  File "C:\Users\gomes\Downloads\pygame_sdl2-master\setuplib.py", line 93, in parse_cflags
    output = subprocess.check_output(command, universal_newlines=True)
  File "C:\Python27\lib\subprocess.py", line 212, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 2] Le fichier spÚcifiÚ est introuvable

I tried to reinstall pygame_sdl2-master, but gave me the same result.

回答1:

You need the appropriate Windows dependencies and cython. I did some researching and testing and found this solution:

  1. Install cython, type this in a terminal:

$ pip install cython

  1. Go to your pygame_sdl2 directory and download the Windows dependencies by typing:

$ git clone https://github.com/renpy/pygame_sdl2_windeps

If it's not in the pygame_sdl2 directory, just move pygame_sdl2_windeps there manually.

  1. Start building the library:

$ python setup.py install



回答2:

I directly download pygame_sdl2_windeps on github. I have copied this one one the pygame_sdl2 directory and use the "python setup.py install" command in the command prompt, and IT WORKS !!!

C:\PGS4A\pygame_sdl2>python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame_sdl2
>>>

Thank you for your help !!!