How to installing Pygame for Python 3.5 via pip?

2019-08-11 08:44发布

问题:

I'm trying to install Pygame for python 3.5 32bit. I have learned that I can open the .whl files provided on the site by using the pip command. The problem is I've tried multiple ways doing this but with constant error.

python -m pip install pygame-1.9.2a0-cp35-none-win32.whl

'python' is not recognized as an internal or external command,
operable program or batch file.

The file I'm trying to install: pygame-1.9.2a0-cp35-none-win32.whl

My python program is located in my programs folder and everything else works fine.

回答1:

You need to add python.exe to your Windows PATH variable.

The is the system variable that the operating system uses to locate the needed executables from the command line or Terminal windows. [1]


Actually there are many methods to set the PATH variable on windows. One way is to type

set PATH=%PATH%;location path of Python.exe

into the windows command-line interpreter (cmd):

set PATH=%PATH%;C:\Python35-32

Now -- before running the pip command -- you need to make sure that either

  • your working directory is set to the same folder where your pygame-1. ... in32.whl file is located
    or
  • you supply the full absolute or relative path to the pip command.

Now you should be able to run your python -m pip command after restarting the cmd.exe.



回答2:

if you get trouble when install pygame error about missing visual studio 10+. I have the answer: the problem is not about have or not have visual studio, because I try many version but it not work. The problem is file: between tar.gz and .whl so, this is the solution:

1) download file:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame go here and download your pygame version, notice about x64 or x86 and python version. my system is x64 and python is 3.4 so I choose: pygame-1.9.2a0-cp34-none-win_amd64.whl

2) put it in some where to install:

I put it in "C:", so open cmd: and type: cd C:\ (this changes the location to C:)

3) install

pip install C:\pygame-1.9.2a0-cp34-none-win_amd64.whl

done !