1

I've repeatedly installed web3 via pip on an ubuntu OS (17.04, running on a DigitalOcean droplet) but for some reason when I attempt to run "from web3 import Web3" I get this response:

ModuleNotFoundError: No module named 'web3'

I think it has to do with pip because I've had trouble installing other modules (eth-testrpc). Any advice?

  • If it's a pip problem with other libraries too, then you probably have an environment setup issue. You can work in a new virtual environment to sidestep it: digitalocean.com/community/tutorials/… The upside is that you should really be working in python 3 anyway for web3.py – carver Oct 6 '17 at 0:11
  • Thanks for the input, carver. I already ran this in a venv...no dice. – Gregory DiPrisco Oct 6 '17 at 3:36
  • 1
    What do you see in your console in response to pip install -U web3? – carver Dec 29 '17 at 23:24
-1

From the terminal, install Web3.py using pip with the following command:

pip install web3

To use the web3 library you will need to instantiate a Web3 object:

>>> from web3 import Web3, HTTPProvider, IPCProvider
>>> web3 = Web3(HTTPProvider('http://localhost:8545'))

>>> web3.eth.blockNumber
4000000

or for an IPC based connection

>>> web3 = Web3(IPCProvider())

Note that you should create only one RPCProvider per process, as it recycles underlying TCP/IP network connections between your process and Ethereum node.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.