Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More pygame errors
#11
Quote:I cannot see any root files as there are only the 2 .py files in that directory.
i mean root file by whatever script starts the program. Root directory being the directory that file is in. The image needs to be in whatever directory the script is that you are running. Otherwise the image needs a path from the root directory to load correctly.
Recommended Tutorials:
Reply
#12
This is the root directory and as far as I can determine the root file.
Both the module/program and the I image files are in the same directory, there is no directories above or below relating to the app (flat directory structure).
Reply
#13
try loading a different png file, as well as a jpg too. Dont just change the filename to jpg, but find one online to load.

EDIT:
I notified other pygamers here of your issue. You can also try pygame reddit to get more pygame user responses. Maybe they might come up with something i didnt think of.
Recommended Tutorials:
Reply
#14
Thank you.

I have attempted other image formats and get the same results
Reply
#15
How are you running the program?
Seems to me that it just can't find the file:
$ python3
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame as pg
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> pg.image.load("snarf")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pygame.error: Couldn't open snarf
>>>
Please provide your exact directory structure and details on how you are attempting to execute it.
Reply
#16
The directory is as follow
C:\Users\******\Downloads\python_game_resourses\ (***** is the user name but for this purpose let's call it Pete).

We are using the python built-in ideas editor (gui :( ) using the run module option on the menus.
Reply
#17
You should first run it through the terminal/command prompt to isolate the problem to your editor or python/pygame.

An IDE/editor can cause weird hard to diagnose problems that is only related to that specific IDE/editor itself
>>> import os
>>> os.getcwd()
and make sure its the same path as you are expecting it to be through the editor. What path are you actually in when you load your image?

(Jan-06-2019, 10:16 AM)PyEH Wrote: We are using the python built-in ideas editor (gui
I have never heard of it. I would use one of the well known IDE's or just use the terminal or command prompt.
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pygame*import pygame ImportError: No module named pygame CASPERHANISCH 1 9,755 Jun-05-2017, 09:50 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020