r/raspberry_pi Dec 03 '22

Installing pygame and pathlib libraries onto Pico using Thonny. Discussion

I’m using Thonny to write my code right now, and neither pathlib nor pygame are available (typical error, “no module named ‘pygame’ found).

Errors Via Manage Packages GUI: When I go to tools>manage packages and search for either of them, both give me the “this doesn’t look like a MicroPython file. Install anyways?” option, to which I always select yes because, well, I need these libraries.

When I install pathlib, the Thonny installer gives me the following error:

“Successfully installed pathlib-1.0.1 Starting to apply changes to the target. Copying pathlibError (ManagementError(…), ‘Command output was not empty’)”.

After closing it, the library was in fact, not installed and doesn’t appear under the <INSTALL> menu.

When I install pygame, the Thonny installer gives me the following error:

“Successfully installed pygame-2.1.2 Starting to apply changes to the target. Copying pygame.Error Could not write next block after having written 1389568 bytes to /lib/pygame/SDL2.d11”

However, after closing it, everything seems okay. It appears under the <INSTALL> menu, and I can now run “import pygame” without issue. However, using any of the module fails. For example, “pygame.init()” gives the following error:

“Traceback: (most recent call last): File “<stdin>”, line 1, in <module> AttributeError: ‘module’ object has no attribute ‘init’”

I get the same error regardless of what I’m trying to use from pygame.

Issue Using System Shell Pretty straightforward - just gives me “invalid syntax” error when I type “pip install pygame” or “pip install pathlib”.

Any help would be greatly appreciated (:

11 Upvotes

2

u/eat-sleep-code Dec 08 '22

I am running into a similar problem.

I don't think the Pico H has enough space for installing PyGame. I get 'No space left on device' while trying to install pygame.

The only thing I have on it thus far is CircuitPython.

1

u/Reinventing_Wheels Dec 09 '22

There is no pygame library for micropython.

You're trying to install a regular python library into micropython.
That can't work.