Unable to install Pygame using pip

2019-01-08 16:28发布

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.

14条回答
Bombasti
2楼-- · 2019-01-08 16:35

Try

python3 -m pip install -U pygame --user

This worked twice for me on windows 7 and windows 10

查看更多
别忘想泡老子
3楼-- · 2019-01-08 16:39

Try doing this:

sudo apt-get install mercurial
sudo pip install hg+http://bitbucket.org/pygame/pygame
查看更多
孤傲高冷的网名
4楼-- · 2019-01-08 16:39

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.

查看更多
乱世女痞
5楼-- · 2019-01-08 16:39

I think if you go to Command Prompt and type

py -m pip install pygame

that's what works for me

查看更多
狗以群分
6楼-- · 2019-01-08 16:40

Try: python -m pip install pygame

Or: py -m pip install pygame

查看更多
霸刀☆藐视天下
7楼-- · 2019-01-08 16:42

I have never used Enthought distribution, but you could try to use Anaconda distribution which is also great too.

Anaconda Distribution (Any OS):

From the docs:

Update conda to the current version. Type the following:

conda update conda

If a newer version of conda is available, type y to update: Proceed ([y]/n)? y

Check to see if a package you have not installed named “pygame” is available from the Anaconda repository (must be connected to the Internet):

conda search pygame

Conda displays a list of all packages with that name on the Anaconda repository, so we know it is available.

Install this package into the current environment:

conda install pygame

Check to see if the newly installed program is in this environment:

conda list

Install on Windows (both python 2.7 and 3.7):

pip install pygame 

Install on raspberry pi:

sudo pip3 install pygame (python 3.7)
sudo pip install pygame (python 2.7)
查看更多
登录 后发表回答