A Python bot can report ModuleNotFoundError even after a successful package install when startup uses a different interpreter. Check the executable, environment and dependency file together. Repeatedly installing the package globally can make the mismatch harder to see.
Inspect the interpreter in use
python --version
python -m pip --version
python -c "import sys; print(sys.executable)"Use the same interpreter name that appears in your startup command; it may be python3. The pip output identifies the environment receiving packages. Compare this with the panel runtime rather than assuming your laptop and hosting container share a Python version.
Choose one environment strategy
On a VPS, create an isolated virtual environment for the application. Python virtual environments are intended to be recreated on the target system, not copied between machines. In a managed bot container, follow its installation mechanism; creating an extra environment is unnecessary if startup will not use it.
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python bot.pyThis Linux example assumes your entry point is bot.py and your reviewed dependency file is requirements.txt. Substitute the actual names. If the venv module is unavailable, use the supported runtime image or install the distribution package on a VPS you administer.
Check the remaining failure
- Read the first missing module or incompatible-version message.
- Check that the dependency is declared; an import name may differ from its package name.
- Check for local files named after libraries, such as discord.py, that shadow the installed package.
- Install into a fresh test environment and start the same entry point.
- Restart the hosted service and confirm that commands and database access work.
Keep a known-working dependency file with your test deployment. Follow the VPS deployment guide when you also manage the operating system.
Sources and references
Hosting documentation. Publication and update dates reflect this edition.
Related articles
- Fixing Node.js Dependency Errors on a Hosted Discord BotCheck the runtime, lockfile, working directory and first startup error before reinstalling packages.2 min read
- Updating a Discord Bot with a Separate Test DeploymentTest dependencies, commands and database changes without running competing copies of your production bot.2 min read
- How to Host a Discord Bot on a Linux VPSDeploy an existing bot as an unprivileged systemd service with protected credentials, controlled restarts and a repeatable update path.4 min read
