Virtual Environments and requirements.txt Best Practices | NodeFlux.eu Docs
Manage Python package dependencies efficiently using virtualenv, pip freeze, and pinned versions.
Steps
- Create a requirements.txt file listing all dependencies needed by your project.
- Pin specific package versions to avoid unexpected breaking changes: requests==2.31.0.
- Do not upload local virtualenv folder (.venv or venv) over SFTP.
- Let NodeFlux automatic runtime installer build the virtual environment inside the container.
- If adding new packages later, update requirements.txt and restart the service to trigger pip install sync.
Notes
- Including un-pinned dependencies can cause deployments to fail when upstream libraries release breaking API changes.
- Virtual environments isolate Python packages per application, preventing system library conflicts.
Related NodeFlux pages
- Running FastAPI and Flask Web Services with Uvicorn/Gunicorn — Deploy high-performance Python web applications and REST APIs using ASGI/WSGI production servers.
- Writing Non-Blocking Concurrency with Python asyncio — Master asynchronous Python event loops, avoid blocking code traps, and handle concurrent tasks.
- Hosting Discord.py and Pycord Bots on NodeFlux — Deploy asynchronous Python Discord bots using discord.py or Pycord with environment variable security.