web3.py on Mac High-Sierra

pyenv のインストール

$ xcode-select --install
$ brew install pyenv readline xz

Pythonのインストール

$ pyenv install --list
$ pyenv install 3.6.5
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.5.tar.xz...
-> https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Installing Python-3.6.5...
python-build: use readline from homebrew
Installed Python-3.6.5 to /Users/drjiro/.pyenv/versions/3.6.5
$ pyenv versions
$ python --version
Python 2.7.15
$ pyenv global 3.6.5
$ python --version
Python 3.6.5

web3.py のインストール

$ pip install web3
Collecting web3
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/45/9a/3f08f27566d8b00fc1b472ce97c858ce6d8cc3794304d8b2ccbc81295747/web3-4.3.0-py3-none-any.whl (121kB)
    100% |████████████████████████████████| 122kB 1.0MB/s
Collecting lru-dict<2.0.0,>=1.1.6 (from web3)
  Downloading https://files.pythonhosted.org/packages/00/a5/32ed6e10246cd341ca8cc205acea5d208e4053f48a4dced2b1b31d45ba3f/lru-dict-1.1.6.tar.gz
Collecting eth-utils<2.0.0,>=1.0.1 (from web3)
  Downloading https://files.pythonhosted.org/packages/67/fd/e37d9b07c3e5acbabb79dc92f46bc0723246a30fbf3fa1242cd208b0bfec/eth_utils-1.0.3-py3-none-any.whl
Collecting eth-account<0.3.0,>=0.2.1 (from web3)
  Downloading https://files.pythonhosted.org/packages/1c/f4/752b666464002dbd30d30443426cd25c045f941ae5f5e7b08eda1aee3c68/eth_account-0.2.3-py3-none-any.whl
Collecting requests<3.0.0,>=2.16.0 (from web3)
  Downloading https://files.pythonhosted.org/packages/cc/15/e1c318dbc20032ffbe5628837ca0de2d5b116ffd1b849c699634010f6a5d/requests-2.19.0-py2.py3-none-any.whl (91kB)
    100% |████████████████████████████████| 92kB 4.9MB/s
Collecting eth-abi<2,>=1.1.1 (from web3)
  Downloading https://files.pythonhosted.org/packages/a2/2b/8529812e103639a6084c9d5d62862052989cf3877a76253509fc6f19eab6/eth_abi-1.1.1-py3-none-any.whl
Collecting eth-hash[pycryptodome] (from web3)
  Downloading https://files.pythonhosted.org/packages/7a/5c/bb45e05e1ef3af007e5fe055eb0b6e0f2ae58a1640f786fad40eb4e94780/eth_hash-0.1.4-py3-none-any.whl
Collecting cytoolz<1.0.0,>=0.9.0; implementation_name == "cpython" (from web3)
  Downloading https://files.pythonhosted.org/packages/36/f4/9728ba01ccb2f55df9a5af029b48ba0aaca1081bbd7823ea2ee223ba7a42/cytoolz-0.9.0.1.tar.gz (443kB)
    100% |████████████████████████████████| 450kB 2.0MB/s
Collecting hexbytes<1.0.0,>=0.1.0 (from web3)
  Downloading https://files.pythonhosted.org/packages/18/bd/21697d93ee2153c8c12253262b740f571e94341d4cee411504032fff3f56/hexbytes-0.1.0-py3-none-any.whl
Collecting websockets<5.0.0,>=4.0.1 (from web3)
  Downloading https://files.pythonhosted.org/packages/4b/95/76a39368d0615c9eb8d26288833438bf8887a73cf9767cc2e6c6d27efeb3/websockets-4.0.1-cp36-cp36m-macosx_10_6_intel.whl (75kB)
    100% |████████████████████████████████| 81kB 3.2MB/s
Collecting eth-keys<0.3.0,>=0.2.0b3 (from eth-account<0.3.0,>=0.2.1->web3)
  Downloading https://files.pythonhosted.org/packages/9b/96/bec507291a2ecac65358b4485282ce02e8c0cdd30980a232791b355a1f5b/eth_keys-0.2.0b3-py3-none-any.whl
Collecting eth-rlp<1,>=0.1.2 (from eth-account<0.3.0,>=0.2.1->web3)
  Downloading https://files.pythonhosted.org/packages/56/4b/b309fb44dd9bb975e84f3d626392eec1eeed0108e55a51cd7dd8956a73ad/eth_rlp-0.1.2-py3-none-any.whl
Collecting attrdict<3,>=2.0.0 (from eth-account<0.3.0,>=0.2.1->web3)
  Downloading https://files.pythonhosted.org/packages/35/bb/bac3e42ae04bc082c28cd8186bfb5b50fb240a4f7419f876c683125ccc8b/attrdict-2.0.0.tar.gz
Collecting eth-keyfile<0.6.0,>=0.5.0 (from eth-account<0.3.0,>=0.2.1->web3)
  Downloading https://files.pythonhosted.org/packages/eb/a5/3615d100b62fbf20fe5d5c0d1d4d7326eac861d260b0cd2a36af2bf8ccb1/eth_keyfile-0.5.1-py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests<3.0.0,>=2.16.0->web3)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 2.9MB/s
Collecting idna<2.8,>=2.5 (from requests<3.0.0,>=2.16.0->web3)
  Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 3.2MB/s
Collecting urllib3<1.24,>=1.21.1 (from requests<3.0.0,>=2.16.0->web3)
  Downloading https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 4.2MB/s
Collecting certifi>=2017.4.17 (from requests<3.0.0,>=2.16.0->web3)
  Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
    100% |████████████████████████████████| 153kB 3.6MB/s
Collecting parsimonious==0.8.0 (from eth-abi<2,>=1.1.1->web3)
  Downloading https://files.pythonhosted.org/packages/4a/89/32c55944cd30dff856f16859ee325b13c83c260d0c56c0eed511e8063c87/parsimonious-0.8.0.tar.gz
Collecting pycryptodome<4,>=3.5.1; extra == "pycryptodome" (from eth-hash[pycryptodome]->web3)
  Downloading https://files.pythonhosted.org/packages/9c/83/8f8a9e94d3cc495dd49082ac79e366b368cd10c8d25734fbcea59de93e5a/pycryptodome-3.6.1-cp36-cp36m-macosx_10_6_intel.whl (7.2MB)
    100% |████████████████████████████████| 7.2MB 206kB/s
Collecting toolz>=0.8.0 (from cytoolz<1.0.0,>=0.9.0; implementation_name == "cpython"->web3)
  Downloading https://files.pythonhosted.org/packages/14/d0/a73c15bbeda3d2e7b381a36afb0d9cd770a9f4adc5d1532691013ba881db/toolz-0.9.0.tar.gz (45kB)
    100% |████████████████████████████████| 51kB 4.0MB/s
Collecting rlp<2,>=0.6.0 (from eth-rlp<1,>=0.1.2->eth-account<0.3.0,>=0.2.1->web3)
  Downloading https://files.pythonhosted.org/packages/b4/dc/a54b93cac06f46ef49b8da6cb06a6bf77ba65bf45dec5c498f51ceefc5c6/rlp-1.0.1-py2.py3-none-any.whl
Collecting six (from attrdict<3,>=2.0.0->eth-account<0.3.0,>=0.2.1->web3)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: lru-dict, pycryptodome, eth-hash, toolz, cytoolz, eth-utils, eth-keys, rlp, hexbytes, eth-rlp, six, attrdict, eth-keyfile, eth-account, chardet, idna, urllib3, certifi, requests, parsimonious, eth-abi, websockets, web3
  Running setup.py install for lru-dict ... done
  Running setup.py install for toolz ... done
  Running setup.py install for cytoolz ... done
  Running setup.py install for attrdict ... done
  Running setup.py install for parsimonious ... done
Successfully installed attrdict-2.0.0 certifi-2018.4.16 chardet-3.0.4 cytoolz-0.9.0.1 eth-abi-1.1.1 eth-account-0.2.3 eth-hash-0.1.4 eth-keyfile-0.5.1 eth-keys-0.2.0b3 eth-rlp-0.1.2 eth-utils-1.0.3 hexbytes-0.1.0 idna-2.7 lru-dict-1.1.6 parsimonious-0.8.0 pycryptodome-3.6.1 requests-2.19.0 rlp-1.0.1 six-1.11.0 toolz-0.9.0 urllib3-1.23 web3-4.3.0 websockets-4.0.1

##
web3.py

>>> my_provider = Web3.IPCProvider('/Users/drjiro/Library/Ethereum/rinkeby/geth.ipc')
>>> w3 = Web3(my_provider)
>>> w3.eth.blockNumber
2458079

参考

https://qiita.com/mogom625/items/b1b673f530a05ec6b423
http://web3py.readthedocs.io/

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください