#๐Ÿ”’ Path wont work

11 messages ยท Page 1 of 1 (latest)

torn cipherBOT
#

@winged violet

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

amber galleon
#

Hello @winged violet, what is the whole error message?

#

Remember to always show the whole error message, even if you're not sure that it helps.

winged violet
#

d:\Project\code\Project.py:16: SyntaxWarning: invalid escape sequence '{'
self.image = pygame.image.load(f"{path}{image}.png")
pygame 2.6.1 (SDL 2.28.4, Python 3.13.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
<unknown>:2: SyntaxWarning: invalid escape sequence '{'
<unknown>:1: SyntaxWarning: invalid escape sequence '{'
File "d:\Project\code\Project.py", line 90, in <module>
player = Player(100, 100, "Idle1", path)
File "d:\Project\code\Project.py", line 16, in init
self.image = pygame.image.load(f"{path}{image}.png")
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: No such file or directory: 'd:\Project\code\game_images\Idle1.png'.

timber apex
timber apex
#

generally for more cleaner code, i'd recommend utilizing pathlib instead of dealing with raw string paths

winged violet
#

never worked with it and the project is not something ill continue working on so it isnt really a problem, but ill keep it in mind when ill be working on later projects

torn cipherBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.