スマートコントラクト機能を備えた分散型アプリケーションプラットフォームである「ETH,Ethereum,イーサリアム」と対話するためのPythonライブラリ「web3.py」のインストールについて解説しています。
■Python
今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)
■web3.pyをインストールする
web3.pyをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。
pip install web3
起動後、上記のコマンドを入力し、Enterキーを押します。
なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。
py -3.8 -m pip install web3
切り替えるために、上記のコマンドを入力し、Enterキーを押します。
Defaulting to user installation because normal site-packages is not writeable
Collecting web3
Downloading web3-5.24.0-py3-none-any.whl (487 kB)
|████████████████████████████████| 487 kB 819 kB/s
Requirement already satisfied: jsonschema<4.0.0,>=3.2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from web3) (3.2.0)
Collecting eth-utils<2.0.0,>=1.9.5
Downloading eth_utils-1.10.0-py3-none-any.whl (24 kB)
Requirement already satisfied: aiohttp<4,>=3.7.4.post0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from web3) (3.7.4.post0)
Collecting ipfshttpclient==0.8.0a2
Downloading ipfshttpclient-0.8.0a2-py3-none-any.whl (82 kB)
|████████████████████████████████| 82 kB 322 kB/s
Collecting lru-dict<2.0.0,>=1.1.6
Downloading lru-dict-1.1.7.tar.gz (10 kB)
Preparing metadata (setup.py) … done
Requirement already satisfied: protobuf<4,>=3.10.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from web3) (3.17.3)
Collecting hexbytes<1.0.0,>=0.1.0
Downloading hexbytes-0.2.2-py3-none-any.whl (6.1 kB)
Requirement already satisfied: pywin32>=223 in c:\users\user_\appdata\roaming\python\python38\site-packages (from web3) (301)
Collecting eth-hash[pycryptodome]<1.0.0,>=0.2.0
Downloading eth_hash-0.3.2-py3-none-any.whl (8.8 kB)
Collecting eth-account<0.6.0,>=0.5.6
Downloading eth_account-0.5.6-py3-none-any.whl (101 kB)
|████████████████████████████████| 101 kB 3.2 MB/s
Requirement already satisfied: websockets<10,>=9.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from web3) (9.1)
Collecting eth-abi<3.0.0,>=2.0.0b6
Downloading eth_abi-2.1.1-py3-none-any.whl (27 kB)
Requirement already satisfied: requests<3.0.0,>=2.16.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from web3) (2.25.1)
Collecting eth-typing<3.0.0,>=2.0.0
Downloading eth_typing-2.2.2-py3-none-any.whl (6.2 kB)
Collecting multiaddr>=0.0.7
Downloading multiaddr-0.0.9-py2.py3-none-any.whl (16 kB)
Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (3.0.1)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (3.7.4.3)
Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (4.0.0)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (5.1.0)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (1.6.3)
Requirement already satisfied: attrs>=17.3.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (21.2.0)
Collecting parsimonious<0.9.0,>=0.8.0
Downloading parsimonious-0.8.1.tar.gz (45 kB)
|████████████████████████████████| 45 kB 914 kB/s
Preparing metadata (setup.py) … done
Collecting eth-keys!=0.3.2,<0.4.0,>=0.2.1
Downloading eth_keys-0.3.3-py3-none-any.whl (20 kB)
Collecting rlp<3,>=1.0.0
Downloading rlp-2.0.1-py2.py3-none-any.whl (20 kB)
Collecting bitarray<1.3.0,>=1.2.1
Downloading bitarray-1.2.2.tar.gz (48 kB)
|████████████████████████████████| 48 kB 1.4 MB/s
Preparing metadata (setup.py) … done
Collecting eth-keyfile<0.6.0,>=0.5.0
Downloading eth_keyfile-0.5.1-py3-none-any.whl (8.3 kB)
Collecting eth-rlp<2,>=0.1.2
Downloading eth_rlp-0.2.1-py3-none-any.whl (5.0 kB)
Requirement already satisfied: pycryptodome<4,>=3.6.6 in c:\users\user_\appdata\roaming\python\python38\site-packages (from eth-hash[pycryptodome]<1.0.0,>=0.2.0->web3) (3.10.1)
Collecting cytoolz<1.0.0,>=0.10.1
Downloading cytoolz-0.11.0-cp38-cp38-win_amd64.whl (368 kB)
|████████████████████████████████| 368 kB 3.3 MB/s
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (0.17.3)
Requirement already satisfied: setuptools in c:\users\user_\appdata\roaming\python\python38\site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (58.3.0)
Requirement already satisfied: six>=1.11.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (1.15.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3.0.0,>=2.16.0->web3) (1.26.5)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3.0.0,>=2.16.0->web3) (2021.5.30)
Requirement already satisfied: idna<3,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3.0.0,>=2.16.0->web3) (2.10)
Requirement already satisfied: toolz>=0.8.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from cytoolz<1.0.0,>=0.10.1->eth-utils<2.0.0,>=1.9.5->web3) (0.11.1)
Collecting varint
Downloading varint-1.0.2.tar.gz (1.9 kB)
Preparing metadata (setup.py) … done
Requirement already satisfied: base58 in c:\users\user_\appdata\roaming\python\python38\site-packages (from multiaddr>=0.0.7->ipfshttpclient==0.8.0a2->web3) (2.1.0)
Collecting netaddr
Downloading netaddr-0.8.0-py2.py3-none-any.whl (1.9 MB)
|████████████████████████████████| 1.9 MB 3.2 MB/s
Building wheels for collected packages: lru-dict, bitarray, parsimonious, varint
Building wheel for lru-dict (setup.py) … done
Created wheel for lru-dict: filename=lru_dict-1.1.7-cp38-cp38-win_amd64.whl size=12746 sha256=2e55d1b27572ebd9a011fa4e5c3a10b60f25fb921b8fa2c1892a2039d953b3c4
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\ab\ed\82\d47759a6e2416fb78d6ee81c02a970a50d5dc6fc270b5a3242
Building wheel for bitarray (setup.py) … done
Created wheel for bitarray: filename=bitarray-1.2.2-cp38-cp38-win_amd64.whl size=55638 sha256=da613e48fd0392bcf89807a808c677e02380e5086445137b4adaff1914cc4f7f
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\41\36\95\5b4eca059535a8400e8f4ca38f4883ea1801bb221fbd8170df
Building wheel for parsimonious (setup.py) … done
Created wheel for parsimonious: filename=parsimonious-0.8.1-py3-none-any.whl size=42724 sha256=769b62775725fd3192541261b7e9645fd735200d2637d2fa6639ecb729cd7563
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\d8\af\19\fb896f509a437aca2dcf62583e84d7fb2cd5b628c1564a609c
Building wheel for varint (setup.py) … done
Created wheel for varint: filename=varint-1.0.2-py3-none-any.whl size=1979 sha256=847dc1236315794f3fa19662a577902912b54cc197797294d36521bca8194d7f
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\cc\a8\a4\4d9e9807c27585dc974fc0e86a3e4345649d71f8a35906d1a8
Successfully built lru-dict bitarray parsimonious varint
Installing collected packages: eth-typing, eth-hash, cytoolz, eth-utils, varint, rlp, parsimonious, netaddr, hexbytes, eth-keys, multiaddr, eth-rlp, eth-keyfile, eth-abi, bitarray, lru-dict, ipfshttpclient, eth-account, web3
Successfully installed bitarray-1.2.2 cytoolz-0.11.0 eth-abi-2.1.1 eth-account-0.5.6 eth-hash-0.3.2 eth-keyfile-0.5.1 eth-keys-0.3.3 eth-rlp-0.2.1 eth-typing-2.2.2 eth-utils-1.10.0 hexbytes-0.2.2 ipfshttpclient-0.8.0a2 lru-dict-1.1.7 multiaddr-0.0.9 netaddr-0.8.0 parsimonious-0.8.1 rlp-2.0.1 varint-1.0.2 web3-5.24.0
Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、web3.pyが正常にインストールされたことになります。
なお、今回はweb3.pyのバージョン5.24.0をインストールしました。
コメント