Python 3.4 FileNotFoundError: [Ernno 2] No such file or directory but the file IS there

Python 3.4 FileNotFoundError: [Ernno 2] No such file or directory but the file IS there

这是我的错误:

但是 'C:/Python34/Python34/build/exe.win32-3.4/library.zip/pygame/freesansbold.ttf' 处有一个文件 看:

当我通过在计算机上从右侧轻扫并输入地址来检查文件时,它也说它不存在。为什么明明是这样!?!?!?

我知道其他人也问过类似的问题,但其中 none 回答了我的问题。 额外的信息: 该程序在 IDLE 中工作正常,但在编译时不工作 我正在使用 Python 3.4 32 位和 Pygame 32 位 我在 Windows 8.1 64 位 我正在尝试制作飞扬的立方体 :P

如果您需要任何额外信息,请直接询问! `

import pygame
import random
import time
pygame.init()

display_width = 1450
display_height = 720
cube_width = 5

white = (255,255,255)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
black = (0,0,0)
lel = (205,205,255)

cube_colour = white

gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('Flappy Cube')
clock = pygame.time.Clock()
dodged = 0


################################################################################
def things_dodged(count):
    font = pygame.font.Font('freesansbold.ttf',50)
    text = font.render("Dodged: "+str(count),True,blue)
    gameDisplay.blit(text,(0,0))
    pygame.display.update()

def cube_draw(cubex, cubey, cube_width, cube_height, colour):
    pygame.draw.rect(gameDisplay, colour, [cubex, cubey, cube_width, cube_height])
    pygame.display.update()

def pipe_draw(pipex,pipey,pipe_width,pipe_height,colour):
    pygame.draw.rect(gameDisplay, colour,[pipex, pipey, pipe_width, pipe_height])

def msg_objects(msg, font):
    msgSurf = font.render(msg, True, blue)
    return msgSurf, msgSurf.get_rect()

def message_display(msg):
    font_size = pygame.font.Font('freesansbold.ttf',72)
    msgSurf, msgRect = msg_objects(msg, font_size)
    msgRect.center = ((display_width /2), (display_height / 2))
    gameDisplay.blit(msgSurf, msgRect)
    pygame.display.update()
    time.sleep(1)
    game_loop()

def crash(msg):
    message_display(msg)
################################################################################    
def game_loop():

    pipex = 500
    pipey = display_height
    pipe_width = 10
    pipe_height10 = random.randint(30,500)

    while pipe_height10 % 30 != 0:
        pipe_height10 = random.randint(30,500) 
    pipe_height = pipe_height10 * -1
    #
    up_pipex = 500
    up_pipey = 0
    up_pipe_width = 10
    up_pipe_height = display_height - (pipe_height * -1) - 80
    ###
    pipex1 = 1000
    pipey1 = display_height
    pipe_width1 = 10
    pipe_height11 = random.randint(30,500)

    while pipe_height11 % 30 != 0:
        pipe_height11 = random.randint(30,500) 
    pipe_height1 = pipe_height11 * -1
    #
    up_pipex1 = 1000
    up_pipey1 = 0
    up_pipe_width1 = 10
    up_pipe_height1 = display_height - (pipe_height1 * -1) - 90
    ###
    cubex = 20
    cubey = (display_height / 2)
    cube_width = 40
    cube_height = 40 

    gameExit = False
    y_change = 0
    dodged = 0

    if dodged==0:
        pipe_speed = -2 

    while not gameExit:
        if dodged>0:
            pipe_speed = -2.5
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    y_change = -3
                elif event.key == pygame.K_p:
                    time.sleep(4)

            else:
                y_change = 2

        cubey += y_change

        gameDisplay.fill(green)

        pipe_draw(pipex, pipey, pipe_width, pipe_height, lel)
        pipe_draw(pipex1, pipey1, pipe_width1, pipe_height1, lel)

        pipe_draw(up_pipex, up_pipey, up_pipe_width, up_pipe_height, lel)
        pipe_draw(up_pipex1, up_pipey1, up_pipe_width1, up_pipe_height1, lel)

        cube_draw(cubex, cubey, cube_width, cube_height, red)
        pipex += pipe_speed
        pipex1 += pipe_speed
        up_pipex += pipe_speed
        up_pipex1 += pipe_speed
        things_dodged(dodged)


        ###
        if cubey < 0 or cubey > display_height - cube_height:
            crash('You Hit The Side!')


        if pipex < cubex + cube_width:
            if display_height + pipe_height < cubey + cube_height or up_pipe_height > cubey:
                crash('You Hit A Pipe!')

            pipe_height10 = random.randint(30,550)
            while pipe_height10 % 30 != 0:
                pipe_height10 = random.randint(30,550) 
            pipe_height = pipe_height10 * -1
            pipex += 1000
            dodged += 1

            up_pipe_height = display_height - (pipe_height * -1) - 120
            up_pipex += 1000

        if pipex1 < cubex + cube_width:
            if display_height + pipe_height1 < cubey + cube_height or up_pipe_height1 > cubey:
                crash('You Hit A Pipe!')

            pipe_height11 = random.randint(30,550)
            while pipe_height11 % 30 != 0:
                pipe_height11 = random.randint(30,550) 
            pipe_height1 = pipe_height11 * -1
            pipex1 += 1000

            up_pipe_height1 = display_height - (pipe_height1 * -1) - 120
            up_pipex1 += 1000

            dodged += 1

        pygame.display.update()
        clock.tick(10000)

##############################################################################
game_loop()
`

编辑:
非常感谢@Martijn Pieters 回答这个问题

您的文件包含在 ZIP 存档中。您的 Windows 资源管理器可能会自动为您解压缩此类文件,但 Python 不能。

提取文件并将其放在其他地方,或者每次从您的程序中打开 zip 文件,每次都将文件提取到一个临时位置,然后 PyGame 从该临时位置加载字体。