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.

    • Related Articles

    • Problems with dependencies when running an automation

      This problem usually occurs when the dependencies installation step is not done correctly. When running the code, a message is displayed regarding the installation of the packages: ModuleNotFoundError: No module named 'botcity’ The first step is to ...
    • Resolving SSL certificate verification issues when running commands using 'pip'

      Access blocks are quite common in corporate environments. As a result, you may encounter problems when trying to use BotCity tools and Python resources on a machine in your company's environment. One problem that may occur in these scenarios is the ...
    • Error Running Edge Browser via Orchestrator: How to Fix It?

      Issue During the execution of robots using the Microsoft Edge browser through the orchestrator, a specific issue was identified: the browser did not start correctly, whereas when running locally, the flow executed normally. The error presented was: ...
    • How to Resolve the Issue of Installation Stuck at 0% in BotCity Studio ?

      Overview If you're trying to install BotCity Studio or start the BotCity Runner and the installation gets stuck at 0%, or you experience authentication or login errors, it is very likely that your corporate environment is blocking the required ...
    • Error Running Wizard.exe: How to Fix It?

      Issue When attempting to start the installation, configuration, or authentication process of the BotCity Runner using the wizard in .exe format, you may encounter difficulties opening the file. This error usually occurs due to company security ...