'Glitch.com with Python
How to create and use Python 3.7 on Glitch.com? I created a project. Default Python version is old.
I used these files to run Python on Glitch:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="bot.")
@bot.event
async def on_ready():
print("Bot ready!")
bot.run("TOKEN_HERE")
python main.py
discord.py==1.2.3
Solution 1:[1]
Okay, the above answer is correct, an extension to that.
use python3 main.py to run your code.
glitch accepts to use start.sh file, that runs the start up script.
If you are using some packages, you will need to install them, which we generally do using pip. But, Glitch pip runtime installs those packages in python 2 directory. So, even after using python3 in start.sh in Glitch project, it doesn't work.
Here's the work around.
Use Python to install packages.
Following codes will do:
python3 -m pip install -U pip
python3 -m pip install -r requirements.txt
python3 main.py
Add above codes in start.sh
- we're first upgrading pip using python3 (which we usually do)
- Install all packages in
requirements.txt( don't forgetshere, I did :|) - start the
main.py
Additionally, if you want to install a package separately, use python3 -m pip install <package_name>.
Have fun. Your project just launched successfully.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
