How to use python on glitch?

I know that glitch officially supports JavaScript but is there anyway to use Python on it? Can someone give me a step-by-step instruction please?

1 Like

creating your python file and then changing package.json should work:

    "start": "python"

How would I import

Open console and write pip3 install

1 Like

Alright, thank you. I’ll try it

Hey @Daksh777 I suggest you take a look at the projects in for some examples of how to work with Python on Glitch. One thing to keep in mind is that if you omit a package.json file and instead include a requirements.txt file, Glitch will automatically install the dependencies from requirements.txt and run the project using Python.

Hope this helps!


I was very busy these days, but now I have tried it but I don’t know how do I start the main file? Can you check my project @cori? It’s wobbly-coast

Hey @Daksh777, with a python project, Glitch looks for a file called in your project’s home directory and runs that when it starts up. You can place code to start your app in that file and go from there.!/hello-flask? might be a good place to look for a working example.

Hey @cori. Can you check why glitch isn’t running my bot? The code is correct, I think I there’s problem with importing modules. Project name: acoustic-burglar

Hey @Daksh777 I’m not quite sure what you’re trying to do in that project, but based on the code you have it’s doing what I would expect.

Having a glitch.json file in your project puts Glitch into “custom app mode” and runs that install and start scripts you’ve defined. In that file you’re telling Glitch to install from requirements.txt and then to start which in turn starts up a minimal Flask app that renders “Hello World!” when requested. All of that works exactly as I’d expect it to.

If you don’t have a glitch.json file but do have a requirrements.txt file then Glitch goes into “Python mode”, automagically installs from requirements.txt and then starts the app using what’s in In there it looks like you might be trying to start a bot, but you’re asking Glitch to run a file called using Python. This code won’t run as long as you have the glitch.json file in place, and if that weren’t there, Glitch wouldn’t be able to find the non-existant file.

Can you help me understand how you’d like this to work?

I want Gltich to start and just install/import all the modules.
Edit: In, I changed the to
Edit 2: Changed to in glitch.json but all I see in the logs is this:

Edit 3: Added python3 in requirements.txt and I see this:

Edit 4: Running python in console gives this:
I don’t think that’s a syntax error since def is used for a function in python

Hey @Daksh777 I’m pretty sure the default version for the python command in the Glitch containers is 2.7, and async calls weren’t introduced until Python 3.3 or so, so if you want to use asynchronous calls you’ll need to use python3 instead of python.

So do I add python3 in the requirements.txt or use python3

You can remove the python3 from your requirements.txt and change python in to python3 and that should suffice to get you past those errors.

Ok I made those changes. So now running python3 in console does not give anything?
The bot still is offline.

Please help me @cori

Hey @Daksh777 this took me a little bit of digging; sorry for the delay!

I think the version of that you’re referencing (version 1.0.0 per /app/discord/ isn’t compatible with the version of Python3 Glitch is currently running - we’re on 3.5.2 and requires 3.5.3.

We have some work ahead of us to update the app containers and installing a newer version of Python3 is in that list, so this may be worth trying again in the not-too-distant future, although I don’t have a specific timeline right now. You could also try downgrading to v0.16.12 of, which doesn’t specifically mention requiring 3.5.3.

Sorry for the inconvenience!

Alright please keep me updated as you update the python version!

Hello guys I just wanted to use python on so I created everything correctly but then to it’s showing The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.check this webpage

i cant use pip help me bro