I tried to set up a Brownie project that looks like this

+- scripts
|  +- package_one
|  |  +- __init__.py
|  |  +- deploy_contract_one.py
|  +- package_two
|  |  +- __init__.py
|  |  +- deploy_contract_two.py
|  +- utils
|     +- __init__.py
|     +- helper.py
+- contracts
+- ...

where the deploy scripts import helper.py as from utils import helper. When I run a python script via the python executable, I can pass the -m flag to tell it the script is in a package, but brownie run doesn't have anything similar.

When I try to run either of my deploy scripts with brownie run package_one.deploy_contract_one, the error is FileNotFoundError: Cannot find package_one.deploy_contract_one.

If I try running with brownie run package_one/deploy_contract_one, then it can find my deploy script, but the error I get is ModuleNotFoundError: No module named 'utils'.

Everything works if I move the deploy and helper scripts to the root scripts folder and use relative imports.

Is it possible for Brownie to run python scripts in packages, or do I need to restructure this project?

1 Answer 1


I figured it out. If I put an __init__.py in my scripts folder and import my helper.py as from scripts.utils import helper, then I can run it as brownie run package_one/deploy_contract_one.

Additionally, if you installed brownie with pipx, you'll need to inject outside packages into your project.

So instead of

pip install matplotlib

It would be

pipx inject eth-brownie matplotlib

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.