我在做一個項目在python的2048年。默認python解釋器在pyinstaller(pygame)
程序運行正常,當雙擊,也通過命令提示符。 < - 這是使用C:\ Python27 \ python.exe
然而,當我使用pyinstaller嘗試,改變成一個可執行文件,下面的代碼給出了一個錯誤:
class newSprite(pygame.sprite.Sprite):
def __init__(self,filename):
if filename != "0.png":
pygame.sprite.Sprite.__init__(self)
self.images=[]
self.images.append(loadImage(filename))
print(self.images[0])
self.image = pygame.Surface.copy(self.images[0])
self.currentImage = 0
self.rect=self.image.get_rect()
self.rect.topleft=(0,0)
self.mask = pygame.mask.from_surface(self.image)
self.angle = 0
做:
gameboard = newSprite("game board.png")
導致
TypeError:descriptor "copy" requires a pygame.surface object but received a "Nonetype".
當我用c運行腳本:\ WINDOWS \ py.exe , 我犯了同樣的錯誤。
我懷疑Pyinstaller使用c:\ Windows \ py.exe而不是c:\ Python27 \ python.exe作爲其解釋器。我該如何解決這個問題?
更新! :看來問題是pyinstaller沒有正確捆綁我的圖像files.I然而無法添加他們儘管規範文件修改 – chuahziyang