Python programming is one of the most popular areas of web development and bot creation. However, shared hosting users often do not have terminal access and assume that running Python scripts is only possible on dedicated or virtual servers. If your hosting supports CloudLinux and cPanel with the Setup Python App feature, you can run Python scripts or bots (like Telegram bots) without needing SSH. This tutorial is designed for both beginners and advanced users and includes a section explaining how to run a Telegram bot.
Prerequisites and Important Notes
- Your hosting must be under CloudLinux and have cPanel control panel.
- The Setup Python App option must be enabled in the panel.
- You must have access to File Manager.
- You do not need SSH or terminal access.
- This method is suitable for running various Python scripts and even Telegram bots.
Guide to Setup Python App Options in cPanel
Option | Description |
---|---|
Python version | Select the appropriate Python version for the project (e.g., 3.10) |
Application Root | The folder where the project files are located (e.g., public_html/telegrambot) |
Application URL | The domain or subdomain on which the Python application runs |
Application Startup File | The name of the main project file (e.g., bot.py or app.py) |
Application Entry Point | The name of the main function or variable for running the application. Usually ‘app’ for Flask and ‘application’ for Django. Not usually needed for simple scripts. |
Passenger Log File | The path to the application’s execution log file (optional) |
Environment Variables | Project environment variables (optional, e.g., for API KEY, etc.) |
Create | Create and activate the Python application |
Restart | Restart the application after each change or library installation |
Run Pip Install | Automatically install the libraries written in requirements.txt (without terminal) |
Step-by-Step Tutorial: Running a Python Script on Hosting Without a Terminal
1. Login to cPanel and the Setup Python App Section
Log in to your cPanel and click on the Setup Python App option in the Software section.

2. Creating a New Python Application
Click on the Create Application button.

Select the desired Python version (e.g., Python 3.10).

In the Application Root field, enter a desired folder such as public_html/telegrambot.
Select the Application URL (the desired domain or subdomain).
Write the Application Startup File, for example, bot.py.
Write the Application Entry Point as app for Flask projects and application for Django projects (leave it blank for a regular script).
Click on Create.
3. Uploading the Python Script File
Go to File Manager and enter the folder you selected in the previous step.
Upload the main script file (e.g., bot.py
), the requirements.txt
file, and other project files.
4. Creating the requirements.txt file and installing libraries
- If your script requires an external library (e.g., Flask or pyTelegramBotAPI), create a text file named
requirements.txt
. - Enter the names of the required libraries, each on a separate line:
pyTelegramBotAPI
requests
- Return to Setup Python App.
- Click the Run Pip Install button to install the libraries.
5. Running the script and viewing the output
- If your project is a web app (Flask, Django), open the domain or subdomain address in a browser and see the result.
- If it is a regular script, the output may be in the form of a text file, sending a message, or another operation.
- After each change or installation of a new library, Restart the application.
Running a Telegram Bot on Shared Hosting (cPanel)
You can also run your Telegram bot on shared hosting. Simply follow the steps above and have the bot.py
and requirements.txt
files ready.
Simple Telegram Bot Code Example (with pyTelegramBotAPI library):
import telebot
TOKEN = "Place your bot token here"
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(message, "Hello! Your bot is ready.")
bot.polling()
- Upload the code above as
bot.py
to your hosting account. - In the
requirements.txt
file, enter only the namepyTelegramBotAPI
. - Create the application through Setup Python App according to the tutorial above and click Run Pip Install.
- Finally, Restart the application.
Note: Running the bot in polling mode may be stopped on shared hosting that limits long-running scripts. For continuous execution or large projects, a VPS or dedicated bot hosting is more suitable.
If you intend to set up the bot with a webhook (for lower resource consumption and no interruption), you can give the domain address to BotFather and replace the polling code with the webhook code.
Frequently Asked Questions (FAQ) and Troubleshooting
- Why does installing libraries give an error?
Enter the library name accurately in requirements.txt. Check the Python version. The hosting space should not be full. - Why does the Telegram bot disconnect or not stay online?
In shared hosting, long processes are usually terminated. It is better to run the bot as a webhook or use a VPS. - I get a ModuleNotFoundError error?
Have you definitely clicked “Run Pip Install”? The requirements.txt file must be in the project path. - Where is the script output?
For a normal script, the output will be in the form of a text file or message in the same project path or Telegram.
Conclusion
In this tutorial, you learned that even without terminal or SSH access, you can easily set up Python scripts, web projects, and even Telegram bots on your shared hosting. The features of the Setup Python App section in the cPanel control panel provide an opportunity for all users to run their Python projects with just a few clicks, without the need for specialized Linux knowledge.
Don’t forget, if your project requires a specific library, simply create a requirements.txt file and easily install all the libraries with the Run Pip Install button. Also, after any changes to the code or libraries, Restart the application for your changes to take effect.
Important Note:
HiData’s Professional Web Hosting and High-Traffic Hosting services allow you to run Python, and you can choose and use these services as a Python Hosting. If you intend to set up a website, web project, or even a Telegram bot with Python, simply order one of these services and immediately benefit from all the Python execution features.
Finally, running Python on shared hosting is no longer a dream; just follow the steps in this tutorial to run any script you want. If you have any questions or problems, you can get help through the comments section of this article or by submitting a ticket to support.
Good luck, and experience the joy of programming on powerful hosting with HiData!