0

I already installed web3 using pip install, but I get the error "ImportError: No module named web3" when I try to use it.

  • 1
    As far as I know pip is a tool for installing and managing Python packages and hence your question might be about web3py, but instead in the tag I see web3js. – Roman Frolov Feb 20 '18 at 21:14
  • Can you post the results of pip freeze? – carver Feb 21 '18 at 19:28
1

Without your source code, it's hard to say exactly what's going wrong. However, you might have mismatched pip and python if your environment already has Python 2 installed and you're attempting to use Python 3.

If I pip install web3 and then create a file with the following contents:

import json
import web3

from web3 import Web3, HTTPProvider, TestRPCProvider

I don't have any problems with it on macOS with Python 3:

$ pip --version

pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

$ python --version

Python 3.6.4

You might consider looking into virtualenv so that you can have a clean Python environment each time you want to work with it. This can also help ensure you have isolation between Python versions and pip installs.

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.