This guide serves as a step by step process for setting up and validating the web3.py
, bit
, and hd-wallet-derive
libraries used to programmatically send and receive transactions over a blockchain network via virtual wallets. Without these libraries, class activities and their associated code will not be able to perform the necessary operations.
Important Notes:
-
It is strongly recommended to create a new Python virtual environment for this unit to prevent cross-dependency issues.
-
Windows users MUST use
git-bash
or Anaconda Prompt, and not the default Windows command prompt when you are requested to open the terminal window to execute commands, depending on the type of task to perform.
If you need additional help in the installation process, you can follow the step by step video guides in the following links.
Open a terminal and execute the following commands to install web3.py
and bit
, respectively. Windows users MUST use the Anaconda Prompt in this section.
-
Open the terminal and run the following command to create a brand new Python virtual environment for this unit.
conda create -n ethereum python=3.7 anaconda
-
Activate the new environment.
conda activate ethereum
-
Use the
pip install
command to download and install theweb3.py
module.pip install web3
-
Use the
pip install
command to download and install thebit
module.pip install bit
Once the web3.py
and bit
modules are downloaded and installed, verify that both installations completed successfully. Windows users MUST use git-bash
in this section.
-
Use the
conda list package_name
command, substitutingpackage_name
withweb3
to verify if theweb3
library installed successfully.conda list web3
-
Use the
conda list package_name
command, substitutingpackage_name
withbit
to verify if thebit
library installed successfully.conda list bit
It can be frustrating when packages do not install correctly, therefore use the below approaches to troubleshoot any installation or usage issues.
In some cases, the Web3.py
library may fail to install in Microsoft Windows due to the need for Microsoft Visual C++ Build Tools. In such an event, following the below steps to resolve the issue:
-
Scroll down the page and click on "Tools for Visual Studio 2019" to reveal the sub-options.
-
Download the "Build Tools for Visual Studio 2019" package.
-
Run the package file and select the C++ build tools option. Then click install.
-
This process takes about 15 minutes
Along the installation process of bit
or web3
you may experience an issue related with the Microsoft Visual C++ Build tools in Windows if you update Windows after installing the build tools, and before installing these Python libraries.
You may see an error message that states that wheel is not supported
, the solution for this issue is to uninstall and reinstall the Microsoft Visual C++ Build Tools.
An out-of-date Anaconda environment can create issues when trying to install new packages. Follow the below steps to update your conda environment.
Important Note: Windows users MUST use the Anaconda Prompt to run these commands.
-
Deactivate your current conda environment. This is required in order to update the global conda environment. Be sure to quit any running applications, such as Jupyter, prior to deactivating the environment.
conda deactivate
-
Update conda.
conda update conda
-
Create a fresh conda environment to use with
web3
andbit
.conda create -n ethereum python=3.7 anaconda
-
Activate the new environment.
conda activate ethereum
-
Install the
web3
andbit
packages.pip install web3
pip install bit
© 2019 Trilogy Education Services, a 2U, Inc. brand. All Rights Reserved.