I was trying to set up my python environment for accessing web3 data, and there was an issue when I tried to import web3 from within Jupyter notebook. It keeps telling me web3 module not found.
Apparently, I should only access web3 from a virtual environment. A virtual environment, it turns out, is a separate environment that you can create that simulates the NPM style of isolated project environments. It allows you to create self-contained dependencies. This is a great article explaining it.
I followed the following steps to get web3 ready from within jupyter notebook:
- Create a new project folder and navigate to it.
- Create a new virtualenv called venv
virtualenv -p python3 venv - Activate new virtual env
source venv/bin/activate
You’re now operating from within virtualenv - Install web3 in virtual env
pip install web3 - Install ipykernel (following this article)
pip install ipykernel - Install a new kernel called web3Project
ipython kernel install --user --name=web3Project - Open jupyter notebook with my shortcut: jn
Navigate to web3Project kernel on the right. Viola:import web3works.