I've been making a small game in pygame where you click on a rectangle, it disappears with a small animation and then pops up in a new random place on the screen. I used pyinstaller to make the file executable so my friends could try out what I made, but when I made the exe with pyinstaller (file) --onefile --noconsole and then opened it in the same folder as my assets folder, this error pops up. Any ideas?
Asked
Active
Viewed 159 times
0
-
*The same folder as my assets folder*. That is not how `pyinstaller` works. It has to pack your assets *inside* the executable, and extract them to a temporary folder at runtime. To tell it what to do, create a `.spec` file. The docs explain how. – BoarGules Sep 10 '21 at 10:04
-
ok, I'll try that :). Should've read the documentation I guess – lomstfer Sep 10 '21 at 10:20
-
1@BoarGules But then how do you explain this?: https://youtu.be/lTxaran0Cig?t=244 – lomstfer Sep 10 '21 at 10:47
-
I would recommend using ``--add-data file.png;new-folder-or-use-. `` Instead of .spec file. It is much faster to learn. [docs](https://pyinstaller.readthedocs.io/en/stable/usage.html#cmdoption-add-data) – gfdsweds Sep 10 '21 at 10:50
-
And actually, to access data files bundled by onefile, you neeed to follow [this](https://stackoverflow.com/a/44352931/14278613) to create a special function to access them. Btw, that method in the video is generally recommended. – gfdsweds Sep 10 '21 at 10:55
-
Still, I don't understand why there's an error. – gfdsweds Sep 10 '21 at 10:56
-
1pleas provide the full error traceback, run the executable from cmd and see the full error, post it here then, the screenshot doesn't help at all, also you could provide a [mre] and the directory structure – Matiiss Sep 10 '21 at 11:49
-
@Matiiss I ran it from cmd but it gave no more error than that, it looked the same as in the screenshot, the game launches (black) and the error window pops up – lomstfer Sep 10 '21 at 12:05
1 Answers
0
I read the comments of the video I watched (https://youtu.be/lTxaran0Cig?t=244), my font was apparently set to None, and when I set it to something it worked. But thanks for all the possible fixes

lomstfer
- 69
- 7
-
if this is the case, could you add the exact change you made to fix the issue? Otherwise someone else finding your question later seeing the same problem won't be able to use your answer. – PirateNinjas Sep 10 '21 at 12:35
-
Please add further details to expand on your answer, such as working code or documentation citations. – Community Sep 10 '21 at 12:36