Windows 7 64bit - Python 2.7.3 64bit installed - P

2019-08-18 23:37发布

I hope someone can help with this.

  • I have installed Python 2.7.3 64 bit version

  • I have Windows 7 64 bit OS

  • I have installed 64 bit versions of Pygame.

They appear to install and the module import without any issue.

When i run some simple script in the console to test:

import pygame

deepblue = (26,0,255)

mintcream = (254,255,250)

pygame.init()

size = (500,500)

surface = pygame.display.set_mode(size)

pygame window opens. the background is black

i then type :

surface.fill(deepblue)

pygame.display.update()

The pygame window should fill with a blue background but just crashes. Showing as not responding.

I have tested the same code on 2.7.3 on linux and it works without any issue.

I read on the official pygame download site that 64 bit user should use the 32 bit version but i get the same result.

On 64 bit machine should i install 32 bit Python and 32 bit Pygame?

Can anyone help with this? Has any one else had the same issue?

Is there a installer that gives Python with Pygame already installed?

Any help much appreciated.

3条回答
Fickle 薄情
2楼-- · 2019-08-19 00:05

There is no 64bit of pygame on official site and in bitbucket repo of it.

Try to download 64bit of pygame from here.

It have a range of pygame packages form python 2.6 to python 3.4 for 64bit and also for 32bit windows.

You should install it in on 64bit Python .

查看更多
Animai°情兽
3楼-- · 2019-08-19 00:12

Thank you very much for your help. It is now fully working.

It has been three days of install and uninstall, reading countless web pages and trying to stay awake at work after it LOL!

trail and error of programming I guess :)

I installed pygame-1.9.2a0.win-amd64-py2.7.exe from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

Which installed Pygame version 1.9.2a0

I changed the code as advised from using update() to flip()

I also used the pygame.event.get within the while loop

The pygame window does not crash as before.

I have added the udpated script so others can benefit

import pygame, sys

running = True

deepblue = (26,0,255)
mintcream = (254,255,250)
pygame.init()
size = (500,500)
surface = pygame.display.set_mode(size)
surface.fill(deepblue)
position = (250,250)
radius = 50
linewidth = 2
pygame.draw.circle(surface, mintcream, position, radius, linewidth)
pygame.display.flip()

while running:
    event = pygame.event.wait()
    if event.type == pygame.QUIT:
        running = False
pygame.quit()
查看更多
【Aperson】
4楼-- · 2019-08-19 00:15

Try this instead of update()

pygame.display.flip()

Also I had the "Not Responding" problem until I added the following to handle events (inside my game while loop):

pygame.event.get()
查看更多
登录 后发表回答