Pygame installation for Python 3.6.0

2019-05-10 12:55发布

问题:

I was using Python 3.5.2 with Pygame 1.9.2 and everything was working fine. Then I decided to try the recently released Python 3.6.0 with a fresh install, but when I tried to reinstall Pygame with this:

pip install pygame

it returned the following:

Collecting pygame
  Downloading pygame-1.9.2.tar.gz (3.0MB)
    100% |████████████████████████████████| 3.0MB 292kB/s
    Complete output from command python setup.py egg_info:


    WARNING, No "Setup" File Exists, Running "config.py"
    Using WINDOWS configuration...

    Path for SDL not found.
    Too bad that is a requirement! Hand-fix the "Setup"
    Path for FONT not found.
    Path for IMAGE not found.
    Path for MIXER not found.
    Path for PNG not found.
    Path for JPEG not found.
    Path for PORTMIDI not found.
    Path for COPYLIB_tiff not found.
    Path for COPYLIB_z not found.
    Path for COPYLIB_vorbis not found.
    Path for COPYLIB_ogg not found.

    If you get compiler errors during install, doublecheck
    the compiler flags in the "Setup" file.


    Continuing With "setup.py"
    Error with the "Setup" file,
    perhaps make a clean copy from "Setup.in".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\rodri\AppData\Local\Temp\pip-build-328x7lme\pygame\setup.py", line 165, in <module>
        extensions = read_setup_file('Setup')
      File "c:\python\lib\distutils\extension.py", line 171, in read_setup_file
        line = expand_makefile_vars(line, vars)
      File "c:\python\lib\distutils\sysconfig.py", line 410, in expand_makefile_vars
        s = s[0:beg] + vars.get(m.group(1)) + s[end:]
    TypeError: must be str, not NoneType

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\rodri\AppData\Local\Temp\pip-build-328x7lme\pygame\

回答1:

I solved this by using the command:

pip install wheel

and then downloaded pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl from here (I'm using a 64-bit Windows). I copied the file to my Python folder then used

pip install pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl

and it worked.



回答2:

I have recently installed PyGame and PyQt5 on a set of Windows machines at school. I uninstalled the existing (2.4) Python. Then I used the installer from Python.org for 3.6.1. I checked the box to put Python in the PATH and used the custom install to install it for all users. That worked fine.

Then to install pygame and PyQt5 I simply opened a Windows Command Prompt (as administrator) and ran "pip3 install pygame" and then "pip3 install pyqt5"

They both worked fine and the whole installation runs well together.