[Python] FileNotFoundError: [WinError 3] Системе не удается найти указанный путь:...

Discussão em 'Python' iniciado por Stack, Junho 7, 2025.

  1. Stack

    Stack Membro Participativo

    Раньше код работал, но потом я переместил несколько независимых файлов и он перестал работать.

    Вот код:

    import arcade

    class Player(arcade.Sprite): def init(self): super().init(scale=4.0)

    self.walk_left_textures = [
    arcade.load_texture("Sprites/left1.png"),
    arcade.load_texture("Sprites/left2.png")
    ]

    self.walk_right_textures = [
    arcade.load_texture("Sprites/right1.png"),
    arcade.load_texture("Sprites/right2.png")
    ]

    self.texture = self.walk_left_textures[0]
    self.current_texture = 0
    self.animation_timer = 0
    self.animation_speed = 0.1

    self.facing_direction = "left"

    def update_animation(self, delta_time: float = 1/60):
    if self.change_x == 0:
    return

    self.animation_timer += delta_time

    if self.animation_timer >= self.animation_speed:
    self.animation_timer = 0
    self.current_texture += 1

    if self.change_x < 0:
    textures = self.walk_left_textures
    self.facing_direction = "left"
    else:
    textures = self.walk_right_textures
    self.facing_direction = "right"

    if self.current_texture >= len(textures):
    self.current_texture = 0

    self.texture = textures[self.current_texture]


    class MyGame(arcade.Window): def init(self): super().init(width=1280, height=720, title="Is never end [v.1.0]") arcade.set_background_color(arcade.color.BABY_BLUE) self.sprite_list = arcade.SpriteList()

    self.player = Player()
    self.player.center_x = 600
    self.player.center_y = 400
    self.sprite_list.append(self.player)

    def on_update(self, delta_time: float):
    self.player.update()
    self.player.update_animation(delta_time)

    def on_draw(self):
    self.clear()
    self.sprite_list.draw(pixelated=True)

    def on_key_press(self, key, modifiers): #speed
    if key == arcade.key.A:
    self.player.change_x = -2 #speed
    elif key == arcade.key.D:
    self.player.change_x = 2 #speed

    def on_key_release(self, key, modifiers):
    if key in (arcade.key.A, arcade.key.D):
    self.player.change_x = 0
    if self.player.facing_direction == "left":
    self.player.texture = self.player.walk_left_textures[0]
    else:
    self.player.texture = self.player.walk_right_textures[0]


    game = MyGame() arcade.run()

    Файлы left1.png и другие действительно лежат в папке и если скопировать директорию в проводнике они открываются, а в коде нет.

    Ошибка:

    FileNotFoundError: [WinError 3] Системе не удается найти указанный путь: 'Sprites\left1.png'

    Continue reading...

Compartilhe esta Página