0

I need to use the Async features found in web3py 6+ as the features I need are not in pre v6 web3py. I manage my env's using anaconda, but eth-brownie is not available via anaconda to my knowledge which means I need to install brownie via pip, pipx, setuptools, etc. into my anaconda environment.

When installing eth-brownie via pip for example, it uninstalls the web3py 6+ from the anaconda env, and installs 5.31 web3py which does not have the Async features I need to use. This also disables anaconda from managing my web3py version and I am unable to make changes using anaconda for particular libraries due to brownie forcing usage of certain packages.

Does eth-brownie require using web3py below version 6? If anyone is using web3py v6 with eth-brownie, any suggestions on what I need to do?

2 Answers 2

1

Brownie is no longer very actively maintained and may not work with the latest Web3.py versions.

You might want to migrate to ApeWorX.

3
  • What is the most recent web3py version that ApeWorX supports? Another requirement I have is I need to have support for unlocking random eth accounts on a local test network (ex: http localhost 8545) through something like hardhat (npx hardhat node) defined in the brownie-config.yaml with the fork param (infura, alchemy, quicknode, etc), WITHOUT actually having the private key of the account simply for testing purposes like you can with brownie when defining the unlock parameter in brownie-config.yaml? Is it possible to fork and unlock accounts without the private key in ApeWorX?
    – josjunior
    May 9, 2023 at 22:21
  • If you have another question, then please open another question on this website using Ask question button. Q&A comments make a poor support forum. May 10, 2023 at 7:26
  • As requested, I posted another question linked at the end of this comment. Would you please kindly kindly clarify the original post? That being: Does eth-brownie require using web3py below version 6? Here is the link to the ApeWorX question: https://ethereum.stackexchange.com/questions/150218/what-version-of-web3py-does-apeworx-support-and-does-it-also-support-account-imp
    – josjunior
    May 14, 2023 at 1:33
0

This answer is a little delayed, but in case anyone else has this issue, I have an answer to the two part question I posted above. The first part of the question I posted was:

Does eth-brownie require using web3py below version 6?

Answer: eth-brownie does have the specific version of "web3==5.31.3" pinned in the requirements.txt file which installs that version of web3py when installing eth-brownie.

However, the eth-brownie devs created a specific flag one can set in case you have a want or need to install different package versions than what are pinned in the requirements.txt file. The README file of the github for eth-brownie does give explicit instructions on how to loosen the pinned package requirements, by setting the environment variable "BROWNIE_LIB=1" if one wants to manage their own package versions and install different package versions.

WARNING: Managing one's own packages and changing package versions pinned in the requirements.txt file may break features of brownie that rely on those pinned specific versions. Make sure you investigate any package changes before you attempt them, because you may break certain features of brownie. In my specific case, this risk is acceptable because I only use brownie for it's command line operations for compiling, running tests, or deploying, and I very rarely import brownie specific packages into my project, as I mainly rely on web3py for all that I need. If you rely on importing specific brownie packages into your project, this solution may not be for you.

Here is the solution to the second part of my original question:

If anyone is using web3py v6 with eth-brownie, any suggestions on what I need to do?

Answer: First, and for reference, here is the link to the specific instruction in the eth-brownie github README but the actual steps are as follows for using a different version of web3py with brownie.

  1. If you are using a virtual environment such as venv or conda, create a separate environment for your project. This isolates your project and its dependencies from your main environment, helping to prevent conflicts. For example, if you are using conda, the command to create a new environment is

    % conda create mycustonenv

Adjust the command for venv if you are using venv.

And if you already have an env, for example with venv or conda, you need to activate it first. To activate a conda env, you type something like:

`% conda activate mycustomenv`

Adjust the command for venv if you are using venv.

  1. Install Brownie as a library in this environment, and if not using an environment, just install the package as usual. Follow the "as a library" installation instructions in this environment. Make sure to set the BROWNIE_LIB environment variable before running the pip install eth-brownie command. Type these statements at the command line:

% export BROWNIE_LIB=1

% pip install eth-brownie

  1. Explicitly install the versions of dependencies you want to use. After installing eth-brownie, use "pip install" to install the versions of packages like web3 that you want to use. Since the pins have been loosened with the "export BROWNIE_LIB=1" command, you should be able to install newer (or older) versions. The command for installing a web3py version 6 or greater would be something like: pip install web3==6.4

This will uninstall any existing web3py version found in the environment you are using, and if not using an environment, it will uninstall from your default packages, in addition to uninstalling any other conflicting packages that were installed with eth-brownie, that the newer version of web3 relies on. You should now have eth-brownie installed with a newer version of web3py, but there will be certain features of eth-brownie that will not work due to package changes that eth-brownie relies on. For those who do not rely on specific brownie libraries to import, this may not be an issue, as it with my specific circumstance.

I hope this helps anyone else who may need to install a newer version 6 of web3 to use with eth-brownie.

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.