pygame for python 2.7.3

2019-07-02 10:28发布

问题:

I had installed python 2.7.3 on windows 7 and now I want pygame for it. I even installed pygame 1.92 a0 but it doesn't seem to be working . Could anybody help to solve this problem? I had also tried with pygame 1.9.1 but when I am typing "import pygame' on gui, I get an error message:

  Traceback (most recent call last):
    File "<pyshell#3>", line 1, in <module>
       import pygame
   ImportError: No module named pygame

Do I need to set any path while installing?

回答1:

You will want to download the version pygame-1.9.2a0.win32-py2.7.msi. You can search for it at this website, or download directly from this page by clicking here. If you download properly, it should run fine. Be sure to uninstall the old versions of pygame first.



回答2:

Just follow the instructions. Hope it helps you.

Source: https://inventwithpython.com/pygame/chapter1.html

Installing Pygame

Pygame does not come with Python. Like Python, Pygame is available for free. You will have to download and install Pygame, which is as easy as downloading and installing the Python interpreter. In a web browser, go to the URL https://www.pygame.org/download.shtml. These instructions assume you have the Windows operating system, but Pygame works the same for every operating system. You need to download the Pygame installer for your operating system and the version of Python you have installed.

You do not want to download the "source" for Pygame, but rather the Pygame "binary" for your operating system. For Windows, download the pygame-1.9.1.win32-py3.2.msi file. (This is Pygame for Python 3.2 on Windows. If you installed a different version of Python (such as 2.7 or 2.6) download the .msi file for your version of Python.) The current version of Pygame at the time this book was written is 1.9.1. If you see a newer version on the website, download and install the newer Pygame.

For MacOS, download the .zip or .dmg file for the version of Python you have and run it.

For Linux, open a terminal and run: sudo apt-get install python-pygame.

On Windows, double-click on the downloaded file to install Pygame.

To check that Pygame installed correctly, type the following into the interactive shell:

>>> import pygame

If nothing appears after you hit the Enter key, then you know Pygame has successfully been installed. If the error ImportError: No module named pygame appears, then try to install Pygame again (and make sure you typed import pygame correctly.