Unable to install Pygame using pip
I'm trying to install Pygame. I am running Windows 7 with Enthought Python Distribution. I successfully installed pip
, but when I try to install Pygame using pip
, I get the following error:
"Could not install requirement Pygame because of HTTP error HTTP error 400: Bad request for URL ..."
I can't find anything about this issue with a Google search, but I did find another Stack Overflow question that prompted the asker to use the following command:
pip install hg+http://bitbucket.org/pygame/pygame
This gave me the following error:
Cannot find command hg
I'm not sure what else to do, as everything I find with a Google search is for Mac, so I don't know how well I can follow those instructions on Windows.
Steps to install PyGame using pip
-
Install build dependencies (on linux):
sudo apt-get build-dep python-pygame
-
Install mercurial to use
hg
(on linux):sudo apt-get install mercurial
On Windows you can use the installer: Download
-
Use pip to install PyGame:
pip install hg+http://bitbucket.org/pygame/pygame
If the above gives
freetype-config: not found
error (on Linux), then trysudo apt-get install libfreetype6-dev
and then repeat 3.
Alternative way:
# Grab source
hg clone https://bitbucket.org/pygame/pygame
# Finally build and install
cd pygame
python setup.py build
sudo python setup.py install
Try doing this:
sudo apt-get install mercurial
sudo pip install hg+http://bitbucket.org/pygame/pygame
An update to this may be required, as it stands in version 1.9.1 it should simply install using:
pip install pygame
However, it look like there is a bug with their pypi repository, see: https://bitbucket.org/pygame/pygame/issues/59/pygame-has-no-pypi-page-and-cant-be
So, if you want the most recent release, you have to point directly at the ftp file ala:
pip install http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz
I suppose this will be fixed in the 1.9.2 release but for now this works.
I would note that the answer supplied by Pratyush works as well, but requires the user to install mercurial if they don't have it and downloads the trunk version, so really, not ideal unless you absolutely need it.
Caveat: I'm not familiar with the Enthought Distribution, so this might not help.
As you're trying to install on Windows, if you don't want to have to mess around with C compilers, there are pre-built binary wheels for pygame here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Select a package appropriate to you python version[0] and Windows architecture [1]. Download to C:\Users\User\Download\pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl
and install with pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl
Mercurial binaries can be found on the same page, if you would like to install from source. This method would mean compiling pygame from source, for which you probably want to use this compiler package.
[0] python --version
[1] powershell "gwmi win32_operatingsystem | select osarchitecture"
Install on MAC:
brew install homebrew/python/pygame