Installing Pygame through Pycharm or System Termin

2019-08-31 19:52发布

问题:

Im currently running Python 3.7.0b4 and attempting to install the Pygame package, however I keep getting the error.

Command "python setup.py egg_info" failed with error code 1 in C:\Users\Jack\AppData\Local\Temp\pycharm-packaging\Pygame\

This is the error produced by the system terminal, another distinct error by Pycharm is:

TypeError: can only concatenate str (not "NoneType") to str

This is for installing Pygame 1.9.3.

My pip is up to date and so is my set-up tools. I have no idea how to progress at this point.

Full system terminal error output.

Collecting Pygame Using cached https://files.pythonhosted.org/packages/61/06/3c25051549c252cc6fde01c8aeae90b96831370884504fe428a623316def/pygame-1.9.3.tar.gz 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 "", line 1, in File "C:\Users\Jack\AppData\Local\Temp\pycharm-packaging\Pygame\setup.py", line 165, in extensions = read_setup_file('Setup') File "C:\Users\Jack\AppData\Local\Programs\Python\Python37\lib\distutils\extension.py", line 171, in read_setup_file line = expand_makefile_vars(line, vars) File "C:\Users\Jack\AppData\Local\Programs\Python\Python37\lib\distutils\sysconfig.py", line 407, in expand_makefile_vars s = s[0:beg] + vars.get(m.group(1)) + s[end:] TypeError: can only concatenate str (not "NoneType") to str


Command "python setup.py egg_info" failed with error code 1 in C:\Users\Jack\AppData\Local\Temp\pycharm-packaging\Pygame\

回答1:

Pygame docs recommends that you use Python version 3.6.1 or greater, so I would suggest you to use the most recent non-beta version. Also, some pygame wheels are not available to this version yet.

After the python installation make sure its added to your PATH variable and try to install Pygame using this command given that you are on windows:

py -m pip install -U pygame --user

If you get a PermissionError then run the command prompt as administrator.