I am trying open a ERC721 smart contract in Brownie on VSCode and loop through the token ids and set the URI of each in each iteration. I execute the script with brownie run scripts/parcel_asset/testpyodbc.py
. I am trying to use an ODBC driver named pyodbc to query an Access database and create a cursor to iterate. It works fine when running as just a python script but Brownie gives a error ModuleNotFoundError: No module named 'pyodbc'
. Is there a way to his odbc with Brownie?
Below is the error I get
nft> brownie run scripts/parcel_asset/testpyodbc.py Brownie v1.17.2 - Python development framework for Ethereum File ".scriptsparcel_assettestpyodbc.py", line 1, in <module> import pyodbc ModuleNotFoundError: No module named 'pyodbc' Terminating local RPC client... PS C:UsersphilkDropboxsmartCitynftOrlandoMagicOrangenft> brownie run scripts/parcel_asset/testpyodbc.py INFO: Could not find files for the given pattern(s). Brownie v1.17.2 - Python development framework for Ethereum NftProject is the active project. import pyodbc ModuleNotFoundError: No module named 'pyodbc' Terminating local RPC client...
Advertisement
Answer
I found this on a Discord channel: brownie is installed to its own virtual environment, if you want other packages to work you have to “inject” them into the brownie virtualenv: When using brownie I can’t use external modules, pip install doesn’t work brownie but full disclosure, i tried this for another package i was working with to no avail.
pipx inject eth-brownie pyodbc
This fixed the problem