Discuss Scratch

-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

I use Turbowarp to package my projects as HTML but I'm hoping there is also a converter/packager for Python.

Our computer science class requires us to code using Pygame in VS Code. I'm having difficulty in learning how to code using Python, so I'd like to know if there are any applications that can convert Scratch projects into Pygame. Please also leave any tips below for transitioning from Scratch to Pygame. I have no knowledge of coding beyond Scratch.

Thank you so much and have a nice day!
yoyo212arQaboos1790
Scratcher
1 post

How Do I Convert a Scratch Project into Python Code?

While there is no official, one-click conversion tool, you can use third-party converter tools like sb3topy or the online codepatch website to translate your Scratch project into Python code.
thanks
0104mymymy
Scratcher
3 posts

How Do I Convert a Scratch Project into Python Code?

You can use https://microbit.org . It's kinda Scratch and you can translate the code into python and JavaScript.
gem1001
Scratcher
500+ posts

How Do I Convert a Scratch Project into Python Code?

There's this, although it is incomplete and seems to be abandoned.
The_Cool_Scratch_Guy
Scratcher
100+ posts

How Do I Convert a Scratch Project into Python Code?

I'm not well-versed in pygame, but here are some general tips for moving from scratch to python:

  • Sprites -> CLASSES
  • Clones -> OBJECTS
  • When I start as a clone -> def __init__(self)
  • There's no “original sprite”, but __init__() can receive parameters, which can make objects different.
  • broadcast-and-wait + my blocks = FUNCTIONS (very powerful!) Functions can return values, which is a lot neater than using global variables like scratch makes you.
  • Classes can inherit each other, which means similar classes don't need lots of duplicated code.
  • Functions inside a class become METHODS. You can call one on an object of the class using the dot and then the method name.
  • Dragging stuff from the backpack -> Importing MODULES
  • Data types may seem confusing, but they're just different types of values. Remember, classes are types too!

Once you get the hang of it, it will feel a lot more flexible and powerful than scratch! Consider the following:

import random
class Blob: 
    def __init__(self, size):
        self.size = size # This gives our blob a size, and a parameter in __init__ can let us choose what size a blob starts as.
    def grow(self, amount):
        self.size += amount # changes the size variable by the amount parameter to make our blob bigger.
blobs = [] # Creates an empty list.
for i in range(10) # Repeat 10 times.
    blobs.append(Blob(random.randint(1, 5))) # Creates a new blob with a random size from 1-5 and adds it to the list.
for blob in blobs: # Iterate over each individual blob in the blobs list.
    blob.grow(random.randint(1,5)) # Makes the blob grow by a random amount.

This code creates a class called Blob, put a bunch of instances of that class in a list, and makes each blob in the list grow. It takes just 11 lines in python, but would be much longer and more complicated in scratch!

Last edited by The_Cool_Scratch_Guy (Jan. 19, 2026 02:11:31)

-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

yoyo212arQaboos1790 wrote:

While there is no official, one-click conversion tool, you can use third-party converter tools like sb3topy or the online codepatch website to translate your Scratch project into Python code.
thanks

Thank you so much for this! Would you know if there'd be any issue if I converted a Turbowarp project?

Last edited by -SamgyeopsaI- (Jan. 19, 2026 16:41:28)

-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

0104mymymy wrote:

You can use https://microbit.org . It's kinda Scratch and you can translate the code into python and JavaScript.

It looks generally quick to learn. Is coding only limited to microbit? Thanks for the suggestion!
-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

gem1001 wrote:

There's this, although it is incomplete and seems to be abandoned.

Ah, thank you. I also stumbled upon this forum. I'm referring to the Github link attached but I don't know how to install “pip install -r requirements.txt”. Any help would be great!
-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

Update!

Everything is working now except for cairosvg. I will tackle that nightmare in the morning.
FlintBirdDuo
New Scratcher
1 post

How Do I Convert a Scratch Project into Python Code?

cool
-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

FlintBirdDuo wrote:

cool
Okay vro
Thanks for your input!
imfh
Scratcher
1000+ posts

How Do I Convert a Scratch Project into Python Code?

-SamgyeopsaI- wrote:

Update!

Everything is working now except for cairosvg. I will tackle that nightmare in the morning.
If you manually convert all of the assets from SVG to PNG, you shouldn't need to worry about CairoSVG. The latest version of Pygame also supports SVGs, so you probably don't actually need to convert them.

Are you getting an error when you try to run the project, or is it just waning that it can't convert the SVGs?
-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

imfh wrote:

-SamgyeopsaI- wrote:

Update!

Everything is working now except for cairosvg. I will tackle that nightmare in the morning.
If you manually convert all of the assets from SVG to PNG, you shouldn't need to worry about CairoSVG. The latest version of Pygame also supports SVGs, so you probably don't actually need to convert them.

Are you getting an error when you try to run the project, or is it just waning that it can't convert the SVGs?
Update!

CairoSVG is working! The SVGs are really high quality. It worked on one project but now I have a new error. When I run “python3 src/run_gui.pyw”, the terminal says “Traceback (most recent call last)… AttributeError: module ‘sb3topy.config’ has no attribute ‘parse_args’”. Gemini is not helping.

I ran all the requirements already—there's just a new error with opening the python launcher. I am using python 3.14. It doesn't work at all if I use an earlier version. Please help! Thank you!

Last edited by -SamgyeopsaI- (Jan. 29, 2026 02:00:37)

MineTurte
Scratcher
1000+ posts

How Do I Convert a Scratch Project into Python Code?

-SamgyeopsaI- wrote:

imfh wrote:

-SamgyeopsaI- wrote:

Update!

Everything is working now except for cairosvg. I will tackle that nightmare in the morning.
If you manually convert all of the assets from SVG to PNG, you shouldn't need to worry about CairoSVG. The latest version of Pygame also supports SVGs, so you probably don't actually need to convert them.

Are you getting an error when you try to run the project, or is it just waning that it can't convert the SVGs?
Update!

CairoSVG is working! The SVGs are really high quality. It worked on one project but now I have a new error. When I run “python3 src/run_gui.pyw”, the terminal says “Traceback (most recent call last)… AttributeError: module ‘sb3topy.config’ has no attribute ‘parse_args’”. Gemini is not helping.

I ran all the requirements already—there's just a new error with opening the python launcher. I am using python 3.14. It doesn't work at all if I use an earlier version. Please help! Thank you!
You'll likely have to show an example of where the module is actually being used and how it's being used. I'm not familiar with sb3topy so I can only help so much but other's might be able to more.
imfh
Scratcher
1000+ posts

How Do I Convert a Scratch Project into Python Code?

-SamgyeopsaI- wrote:

-snip-
CairoSVG is working! The SVGs are really high quality. It worked on one project but now I have a new error. When I run “python3 src/run_gui.pyw”, the terminal says “Traceback (most recent call last)… AttributeError: module ‘sb3topy.config’ has no attribute ‘parse_args’”. Gemini is not helping.

I ran all the requirements already—there's just a new error with opening the python launcher. I am using python 3.14. It doesn't work at all if I use an earlier version. Please help! Thank you!
If you cloned the project using git, could you run git diff and paste the output? It sounds like you changed something in the code. If you didn't mean to change something, you can reset the code with git reset –hard, or you could redownload the project. I can help fix it if you changed something on purpose though.

I tried running with Python 3.14, and I didn't get the error you described. Not sure how it would work once and then give weird import errors if something didn't change in the code…
MonkeyBean2
Scratcher
500+ posts

How Do I Convert a Scratch Project into Python Code?

You could download the project as an .sb3, then unzip it and have an LLM port project.json to python
-SamgyeopsaI-
Scratcher
9 posts

How Do I Convert a Scratch Project into Python Code?

imfh wrote:

-SamgyeopsaI- wrote:

-snip-
CairoSVG is working! The SVGs are really high quality. It worked on one project but now I have a new error. When I run “python3 src/run_gui.pyw”, the terminal says “Traceback (most recent call last)… AttributeError: module ‘sb3topy.config’ has no attribute ‘parse_args’”. Gemini is not helping.

I ran all the requirements already—there's just a new error with opening the python launcher. I am using python 3.14. It doesn't work at all if I use an earlier version. Please help! Thank you!
If you cloned the project using git, could you run git diff and paste the output? It sounds like you changed something in the code. If you didn't mean to change something, you can reset the code with git reset –hard, or you could redownload the project. I can help fix it if you changed something on purpose though.

I tried running with Python 3.14, and I didn't get the error you described. Not sure how it would work once and then give weird import errors if something didn't change in the code…

Sorry for the late updates… It's fully working now! I just have to tweak the sprite costumes a bit. May I know if it's compatible with Turbowarp modified projects? Like if the project is 60 FPS or a different screen size? Thank you so much for all your help!

Powered by DjangoBB