Skip to content
Advertisement

ModuleNotFoundError : No module named with locust

When I try to import external library of my project in my locust python file, each time I have the error “ModuleNotFoundError : No module name ‘…’.

Apparently is not clear but locust is installed and works. I have a task to make REST API call and it’s ok. But I need to make some action in the init method coming from external file of my project

Example :

I want to import the method “generateILogsToken” in my locust file from _Global.py file

FILE : getWalletInfoLocust.py

JavaScript

Error generated with the command locust -f getWalletInfoLocust.py

JavaScript

I have this issue for any method imported from external file of my project. When I’m used behave or other, no isse. It’s only with locust.

Thx

Advertisement

Answer

I am not sure, but I think the problem could be related to the fact that you launch your program in a folder that is not the root folder of your project.

Let’s say you have a directory tree like this:

JavaScript

When launching the command, python will look for the Phoenix folder from the folder you are launching python from.

To be sure the module is found, you should launch locust -f getWalletInfoLocust.py from the directory that I called “project_directory” in my example, otherwise python could not find the module Phoenix.

Alternatively you can add your root directory to sys.path in your file, like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement