I am trying to setup eth-brownie
to get a feel of the framework but face a couple of import-related problems.
Im working from a MBP running macOS with Catalina v10.15.7
$ python --version
Python 3.9.9
I have followed the recommendations from https://eth-brownie.readthedocs.io/en/stable/install.html and could get brownie
to run fine in CLI.
See following:
$ pipx list
venvs are in /Users/julien.couvy/.local/pipx/venvs
apps are exposed on your $PATH at /Users/julien.couvy/.local/bin
package eth-brownie 1.17.1, Python 3.9.9
- brownie
$ brownie --version
Brownie v1.17.1 - Python development framework for Ethereum
I have tried compiling a sample brownie-box and run the tests, which worked fine.
brownie test
Brownie v1.17.1 - Python development framework for Ethereum
Compiling contracts...
Solc version: 0.6.12
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
Generating build data...
- SafeMath
- Token
=============================================================================================================== test session starts ===============================================================================================================
platform darwin -- Python 3.9.9, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /Users/(...)/sample-contracts/token
plugins: eth-brownie-1.17.1, web3-5.24.0, hypothesis-6.24.0, xdist-1.34.0, forked-1.3.0
collected 38 items
Launching 'ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
tests/test_approve.py ............ [ 31%]
tests/test_transfer.py ......... [ 55%]
tests/test_transferFrom.py ................. [100%]
=============================================================================================================== 38 passed in 10.93s ===============================================================================================================
Terminating local RPC client...
When trying to import brownie
in a python program via VSCode, it does not resolve. This is probably due to the fact that VSCode does not manage to find the venv
used by pipx
.
Moreover, I cannot run any individual script using brownie run
, see example:
$ brownie run scripts/token.py
Brownie v1.17.1 - Python development framework for Ethereum
TokenProject is the active project.
Launching 'ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
File "brownie/_cli/run.py", line 50, 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/[email protected]/3.9.9/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
ModuleNotFoundError: No module named 'Users.eval'
Terminating local RPC client...
I have tried installing eth-brownie
using pip3
in a dedicated venv
instead of going the pipx
route. This seem to allow VSCode to find the module, but still cannot use brownie run