简体   繁体   中英

Pygame on ubuntu doesn't work

I just installed Ubuntu to my computer, and I wanted to work on my .py project, so I did install Pyzo and Miniconda, and did a bunch of stuff to get Python3 and pygame. So, right now, it seems like Python is ok with importing pygame, but when the first line including some pygame comes in, there is an error.

Exemple :

ico = pygame.image.load('data\\\\png\\\\favicon.png').convert_alpha()

=>

pygame.error: Couldn't open data\\png\\favicon.png

By the way, it's working properly on all my other computers. And I'm running the file as a script, with the data folder in the same folder.

I tried to use Sublime Text 3, but I can't run anything 'cause my build is probably not good :

{
  "cmd": ["/usr/bin/python3", "-u", "$file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.python",
  "shell":"true"
}

EDIT :

I replaced all those "\\\\" in "/" and it works fine ! But Sublime Text still not working properly

The load method should be like this:

ico = pygame.image.load('data/png/favicon.png').convert_alpha()

Also, this will only work if your path is correct, so double check it if it doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM