Skip to Content
Hands-On Blockchain for Python Developers
book

Hands-On Blockchain for Python Developers

by Arjuna Sky Kok
February 2019
Intermediate to advanced
450 pages
9h 59m
English
Packt Publishing
Content preview from Hands-On Blockchain for Python Developers

Installing web3

Without further ado, let's install the web3 library. Create a virtual environment with Python 3.6 as follows:

$ virtualenv -p python3.6 web3-venv

Activate the virtual environment and install Vyper as follows:

$ source web3-venv/bin/activate(web3-venv) $ pip install vyper

Then, install the web3.py library using pip:

(vyper-venv) $ pip install web3

Now, verify whether it works as follows:

(vyper-venv) $ python>>> import web3>>> web3.__version__'4.8.2'

If you don't encounter any errors, it works. Let's connect to the Ganache blockchain with web3. To do this, first fire up Ganache, and then go back to your Python Command Prompt:

>>> from web3 import Web3, HTTPProvider>>> w3 = Web3(HTTPProvider('http://localhost:7545'))>>> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain in Action

Blockchain in Action

Bina Ramamurthy
Learn Python by Building a Blockchain and Cryptocurrency

Learn Python by Building a Blockchain and Cryptocurrency

Academind by Maximilian Schwarzmüller GmbH

Publisher Resources

ISBN: 9781788627856Supplemental Content