eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
https://eth-brownie.readthedocs.io
MIT License
2.65k stars 553 forks source link

ModuleNotFoundError: No module named 'Users.<name>' when running deploy script #1081

Open 0xpetersatoshi opened 3 years ago

0xpetersatoshi commented 3 years ago

Environment information

What was wrong?

I am trying to run this deploy script:

brownie run deploy.py --network development

But I am getting the following error:

Brownie v1.14.6 - Python development framework for Ethereum

BrownieTestTokenProject is the active project.
/Users/peter.begle/.local/pipx/venvs/eth-brownie/lib/python3.9/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 2
  warnings.warn(
Attached to local RPC client listening at '127.0.0.1:8545'...
  File "brownie/_cli/run.py", line 49, in main
    return_value, frame = run(
  File "brownie/project/scripts.py", line 53, in run
    module = _import_from_path(script)
  File "brownie/project/scripts.py", line 149, in _import_from_path
    _import_cache[import_str] = importlib.import_module(import_str)
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
ModuleNotFoundError: No module named 'Users.peter'

How can it be fixed?

Fill this in if you know how the bug could be fixed.

iamdefinitelyahuman commented 3 years ago

Can you share the source for the script you're trying to run? Or even better, is it in a public repo you can link to?

aspin commented 3 years ago

I get this too. From what I can tell, the script runner is trying to load the absolute path of the script, which starts with Users.<username>. I'm not really sure what the expected behavior is.

scripts/deploy.py

import brownie

def main():
    acct = brownie.accounts.load('metamask')
    brownie.Storage.deploy('Storage', 'BLXS', 18, 1e28, {'from': acct})

if __name__ == "__main__":
    main()
aspin commented 3 years ago

For me, this PR fixes the issue: https://github.com/eth-brownie/brownie/pull/1070

akashsenta13 commented 3 years ago

I am also getting similar issue with python3.9 and brownie. Please help.