Requirements.txt for Python Hosting: A Deployment Checklist
Make dependency installation repeatable without uploading your entire local Python environment.
The requirements.txt file tells a Python host which packages to install before it starts your app or bot. It should describe the packages your code imports, with versions stable enough for repeatable deployments. Uploading a local virtualenv instead is usually unreliable because it contains platform-specific paths and binaries.
Start with direct dependencies
Write one package per line. Package names can differ from import names: the module you import is not always the name pip installs. Check the package's official installation instructions when unsure. For a small Telegram bot, a file might look like this:
python-telegram-bot>=21,<23
httpx>=0.27,<1
Do not copy every package from a large workstation environment without reviewing it. A blanket pip freeze may include notebooks, development tools and unrelated libraries. For an existing working virtualenv, pip freeze can be a starting inventory; remove unrelated packages and test in a clean environment.
Test the file before deploying
Create a new local virtualenv, install with pip install -r requirements.txt, and run the entry file. This catches missing dependencies before you involve the host. If installation fails on a server, read the first pip error. “No matching distribution” can mean the version is incompatible with the host's Python version. A compiler or missing system-library error means that pip alone may not be enough.
Keep secrets out of dependencies
requirements.txt is for packages, not bot tokens, database URLs or passwords. Put secrets in environment variables. Commit the file, but not your .env file. After a successful deployment, record the versions that work and update them deliberately. A pinned or bounded version is often safer than silently accepting a major release.
Explore PyHost plans and deploy your Python code from the browser.
Explore hosting plans