Ask coding questions

← Back to all posts
Problems running replit-play in repl.it
glrudolph (1)

This week there was a feature in the repl.it newsletter on replit-play. It was able to run the cat example in the author's example repl, but when I tried to run the same code in my own repl, Some packages would install and compile, but other packages would install but not run. Here are the results:

Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Loading chipmunk for Linux (64bit) [/home/runner/.local/lib/python3.6/site-packages/pymunk/libchipmunk.so]
Traceback (most recent call last):
File "main.py", line 1, in <module>
import play
File "/home/runner/.local/lib/python3.6/site-packages/play/init.py", line 3, in <module>
from .play import *
File "/home/runner/.local/lib/python3.6/site-packages/play/play.py", line 88, in <module>
_pygame_display = pygame.display.set_mode((screen.width, screen.height), pygame.DOUBLEBUF)
pygame.error: No available video device

I was running this from Chrome browser, but same results in Firefox and Edge browsers...
Some thing about my repl.it configuration--such as the author was running Python 3.6.7, my repls run 3.6.1--is different enoughto cause problems.

I am assuming anyone who looks at this post can find the repl.it newsletter and run the same example, so I'm not posting code here.

Answered by heyitsmarcus (287) [earned 5 cycles]
View Answer
Commentshotnewtop
heyitsmarcus (287)

Be sure that when you're trying to run a Pygame game, choose Pygame as the language, because it will load the additional modules needed for Pygame in addition to v3.6.7 of Python. I'm thinking that the generic Python (Python3) doesn't load the necessary video/audio modules.

Here's an example with your code:
https://repl.it/@heyitsmarcus/Test-Pygame

If this solved your problem, please upvote and accept my answer as the correct answer to close this question. I'll continue to answer any questions you may have.

glrudolph (1)

@heyitsmarcus That worked. From the original documentation on replit-play, I wouldn't have known that pygame is a dependency, and I would have expected the package loading scripts and whatever else runs to correctly load and configure the video drivers.

In any case, this solved the problem, so now I know how to tell myself and my students what to do to use replit-play in assignments.

heyitsmarcus (287)

@glrudolph It is interesting that it didn't load pygame as a dependency. I'm just glad you and your students aren't stuck! Happy coding!

glrudolph (1)

@heyitsmarcus It looks like it loads pygame, but not configured properly.

glrudolph (1)

@heyitsmarcus my mistake. I meant to say that in a plain Python 3 repl, the script appears to install pygame as expected, but pygame doesn't load and run because of the video drivers. The latter is what I meant by "not configured properly".

heyitsmarcus (287)

@glrudolph You're right. The Python3 repl should be able to resolve dependencies and/or modules needed for Pygame. I think it's time for a feature request: https://repl.it/feedback