9

I've recently installed and have been playing around with Bash on Ubuntu on Windows. For the most part it works great. I'm trying to run a pygame script through BUW but it doesn't render the graphics in a popup window. Instead, it seems to be contained in the bash window and looks like this:

enter image description here

Is this a lost cause for pygame? Is there anything I can do here to make it run?

Null Salad
  • 765
  • 2
  • 16
  • 31

3 Answers3

5

Pygame runs on SDL. The SDL version shipped with ubuntu requires* an xserver to run. Find out how to run an xserver with bash on ubuntu on windows.

This question might provide those steps: How to use X Windows with Emacs on Windows 10 Bash?

*It requires something to render to, raw framebuffers and,as you noticed, libcaca, which renders bitmaps to ascii art, are also fine. Rendering to X is the one you probably want, though.

Lanting
  • 3,060
  • 12
  • 28
2

From the FAQ on the page you linked to:

Can I run ALL Linux apps in WSL?

No! WSL is a tool aimed at enabling users who need them to run Bash and core Linux command-line tools on Windows.

WSL does not aim to support GUI desktops or applications (e.g. Gnome, KDE, etc.)

Dunes
  • 37,291
  • 7
  • 81
  • 97
  • 3
    In WSL2 with Windows 2004 you can install an X server and run any Linux applications. – nowox Sep 08 '20 at 16:44
2

Update from 2021: With WSL2 I followed these steps to run PyGame

  1. Download and install Xlaunch. Run it with all default settings except check "Disable access control"

  2. Add the following code to the top of the python file:

import os
os.environ["SDL_VIDEODRIVER"]="x11"
Jonah Kornberg
  • 153
  • 1
  • 8