How can I successfully install pygame into python3

2019-08-31 08:30发布

问题:

I had successfully installed pygame in python2 using pip on Mac. But I was unable to install pygame in python3.

After entering the following commands:

$ brew install hg sol sdl_image sdl_ttf
$ brew install sdl_mixer portmidi
$ pip3 install --user hg_http://bitbucket.org/pygame/pygame

I got:

Failed building wheel for pygame
  Running setup.py clean for pygame
Failed to build pygame
Installing collected packages: pygame
  Running setup.py install for pygame ... error

And:

36 warnings and 8 errors generated.
    error: command 'clang' failed with exit status 1

I had ensured that I installed wheel and the newest version of setuptools. I tried again using the command:

$ pip3 install pygame

I still got:

Failed building wheel for pygame
  Running setup.py clean for pygame
Failed to build pygame
Installing collected packages: pygame
  Running setup.py install for pygame ... error

Other syntaxes I had tried:

$ pip3 install Pygame==1.9.3
$ python3 -m pip install pygame

But all of them generated the same error.

So, how can I successfully install pygame in python3?

回答1:

You need to use pip just enter

    python3 -m pip install pygame

Here is a link that can be helpful

http://medium.com/@louiscouture/tl-dr-pip-bcddaca44540 You basically used the wrong syntax for pip.