How to Resolve the “ModuleNotFoundError” When Running Your Automation?

How to Resolve the “ModuleNotFoundError” When Running Your Automation?

Overview

If you encounter the following error when running your automation:

WarningModuleNotFoundError: No module named 'botcity' 
this means the Python environment being used to run the automation cannot find the required package. This issue is typically caused by dependencies not being installed correctly or by using a different Python interpreter during execution than the one used for installation.Common Cause

One of the most frequent scenarios occurs when:

  • The IDE (e.g., PyCharm, VSCode) automatically creates a virtual environment for your project.

  • Dependencies are installed inside this virtual environment.

  • The script is executed using the system-wide (global) Python interpreter, rather than the virtual environment.

In this case, the global Python environment does not have access to the packages (like botcity), resulting in the ModuleNotFoundError.


Solution

Step 1: Verify the Python Interpreter

  • Make sure the same Python interpreter is used to install dependencies and to run the automation.

  • If you're using a virtual environment, ensure it is activated before executing any commands.

Step 2: Install the Dependencies Properly

Using the correct environment or interpreter, run:

Notes
pip install --upgrade -r requirements.txt

This will install (or update) all required dependencies as listed in your project’s requirements.txt file.

Step 3: Run the Automation Using the Same Interpreter

Always execute your automation using the same Python environment in which the dependencies were installed.


Note When Using BotCity Runner

If you’re running your automation with BotCity Runner and encounter similar errors for other libraries, make sure:

  • The missing module is correctly listed in the requirements.txt file of your automation.

  • BotCity Runner relies on this file to install all necessary packages during task execution.


Conclusion

The ModuleNotFoundError is usually caused by a mismatch between the environment where dependencies were installed and the one used to execute the automation. Ensuring consistency between these environments is key to resolving this issue.