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:

  1. Create a new project folder and navigate to it.
  2. Create a new virtualenv called venv
    virtualenv -p python3 venv
  3. Activate new virtual env
    source venv/bin/activate
    You’re now operating from within virtualenv
  4. Install web3 in virtual env
    pip install web3
  5. Install ipykernel (following this article)
    pip install ipykernel
  6. Install a new kernel called web3Project
    ipython kernel install --user --name=web3Project
  7. Open jupyter notebook with my shortcut: jn
    Navigate to web3Project kernel on the right. Viola: import web3 works.