简体   繁体   中英

Use external packages in eth-brownie?

i am trying open a ERC721 smart contract in Brownie on VSCode and loop through the token ids and set the URI of each of 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 ".\scripts\parcel_asset\testpyodbc.py", line 1, in <module>
import pyodbc
ModuleNotFoundError: No module named 'pyodbc'
Terminating local RPC client...
PS C:\Users\philk\Dropbox\smartCity\nft\OrlandoMagicOrange\nft> 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...

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.

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

pipx installs packages into a siloed virtual environment, so you have to install into that the brownie virtual environment to use other packages.

Related from Stack Exchange Ethereum

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM