11Troubleshooting
2- =============================
2+ ===============
33
44.. _setup_environment :
55
66Set up a clean environment
7- ----------------------------------------------
7+ --------------------------
88
99Many things can cause a broken environment. You might be on an unsupported version of Python.
1010Another package might be installed that has a name or version conflict.
@@ -36,10 +36,36 @@ Often, the best way to guarantee a correct environment is with ``virtualenv``, l
3636 .. NOTE :: Remember that each new terminal session requires you to reactivate your virtualenv, like:
3737 ``$ source ~/.venv-py3/bin/activate ``
3838
39+
40+ .. _instance_troubleshooting :
41+
42+ Why can't I use a particular function?
43+ --------------------------------------
44+
45+ Note that a Web3.py instance must be configured before you can use most of its capabilities.
46+ One symptom of not configuring the instance first is an error that looks something like this:
47+ ``AttributeError: type object 'Web3' has no attribute 'eth' ``.
48+
49+ To properly configure your Web3.py instance, specify which provider you're using to connect to the
50+ Ethereum network. An example configuration, if you're connecting to a locally run node, might be:
51+
52+ .. code-block :: python
53+
54+ >> > from web3 import Web3
55+ >> > w3 = Web3(Web3.HTTPProvider(' http://localhost:8545' ))
56+
57+ # now `w3` is available to use:
58+ >> > w3.isConnected()
59+ True
60+ >> > w3.eth.send_transaction(... )
61+
62+ Refer to the :ref: `providers ` documentation for further help with configuration.
63+
64+
3965.. _use_metamask_accounts :
4066
4167Why isn't my web3 instance connecting to the network?
42- --------------------------------------------------------
68+ -----------------------------------------------------
4369You can check that your instance is connected via the ``isConnected `` method:
4470
4571.. code-block :: python
@@ -57,7 +83,7 @@ Provider configuration issue. There are several options for configuring
5783a Provider, detailed :ref: `here<providers> `.
5884
5985How do I use my MetaMask accounts from Web3.py?
60- --------------------------------------------------------
86+ -----------------------------------------------
6187Often you don't need to do this, just make a new account in Web3.py,
6288and transfer funds from your MetaMask account into it. But if you must...
6389
@@ -71,7 +97,7 @@ and :ref:`eth-account`.
7197.. _faucets :
7298
7399How do I get ether for my test network?
74- --------------------------------------------------------
100+ ---------------------------------------
75101
76102Test networks usually have something called a "faucet" to
77103help get test ether to people who want to use it. The faucet
0 commit comments