Installing pygame with pip: Command “python setup.

2019-02-27 00:41发布

问题:

I have only recently started to learn programming with python. Currently I am trying to install pygame but I am constantly gettting the same error:

C:\WINDOWS\system32>python -m pip install pygame
Collecting pygame
Using cached pygame-1.9.2.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 "<string>", line 1, in <module>
  File "c:\users\filip\appdata\local\temp\pip-build-0xsf1b\pygame\setup.py", line 165, in <module>
    extensions = read_setup_file('Setup')
  File "C:\Python33\lib\distutils\extension.py", line 164, in read_setup_file
    line = expand_makefile_vars(line, vars)
  File "C:\Python33\lib\distutils\sysconfig.py", line 430, in expand_makefile_vars
    s = s[0:beg] + vars.get(m.group(1)) + s[end:]
TypeError: Can't convert 'NoneType' object to str implicitly

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\filip\appdata\local\temp\pip-build-0xsf1b\pygame\

I already went through a number of posts with similar problems but none of them had the exactly same issue, and/or they were concerned with different packages and operating systems. Moreover, I tried a couple of solutions to those problems but nothing worked for me (i tried upgrading pip, installing with easy_install and some other options I, unfortunately, cannot even recall at this point...).

I would be sincerely grateful if someone can help me with this problem. I am aware that it is possibly an irrelevant or "newbie" question, but I honestly tried finding a solution on my own and really have no more clue what to do. I have also never been really educated in computer science, so all of these things frustrate and confuse the hell out of me and constantly get in the way of the learning process (which is hard enough).

I am using Windows 10, python 3.3 64-bit.

Thank you!

回答1:

Another way to install pygame, which worked for me (W10 64bit, Python 3.4.5).

Head here and download the correct pygame wheel file for your version. Then, from cmd, go to the directory the file is in, and type pip install [COMPLETE EXACT FILENAME].

Good luck!



回答2:

I had the same problem but i solved it by updating pip



回答3:

Try upgrading pip. Simply open your command line (search cmd in your task bar search box) and enter the command below:

pip install --upgrade pip


回答4:

Try install pygame from this repository: http://www.lfd.uci.edu/~gohlke/pythonlibs/

It is not a official place, but it is trusted. I was having this same problem, and I resolved it installing the package (pygame) from this website. You just have to download the intended".whl" file and install with "pip" from the place where your download is placed.

Don't forget uninstall the previous Pygame installed. =)



回答5:

Check your mysql configuration file using this:

mysql_config

Now you should get an output something like this:

mysql_config 
Usage: /usr/bin/mysql_config [OPTIONS]
Compiler: GNU 6.3.0
Options:
        --cflags         [-I/usr/include/mysql ]
        --cxxflags       [-I/usr/include/mysql ]
        --include        [-I/usr/include/mysql]
        --libs           [-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl]
        --libs_r         [-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl]
        --plugindir      [/usr/lib/mysql/plugin]
        --socket         [/var/run/mysqld/mysqld.sock]
        --port           [0]
        --version        [5.7.18]
        --libmysqld-libs [-L/usr/lib/x86_64-linux-gnu -lmysqld -lpthread -lz -lm -lrt -latomic -lcrypt -ldl -laio -llz4 -lnuma]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/include/mysql]
                pkglibdir     [/usr/lib/x86_64-linux-gnu]
                plugindir     [/usr/lib/mysql/plugin]

Ideally it should contain libmysqld-libs option. If it is not there, as it was not there in my case, you can assume that your mysql is broken.

In this case you can write this configuration to config file directly



回答6:

Just downgrade your Python version. Uninstall your current Python and delete uninstalled python folder, then install python3.5.

Last, you can use the command line:

pip3 install pygame

It worked for me.