我在ubuntu上通过pip多次安装了web3 (17.04,运行在DigitalOcean液滴上),但由于某种原因,当我试图运行“从web3导入Web3”时,会得到以下响应:
ModuleNotFoundError:没有名为“web3”的模块
我认为这与pip有关,因为我在安装其他模块(Eth)时遇到了困难。有什么建议吗?
发布于 2017-12-29 17:05:34
在终端中,使用pip使用以下命令安装Web3.py:
pip install web3要使用web3库,您需要实例化一个Web3对象:
>>> from web3 import Web3, HTTPProvider, IPCProvider
>>> web3 = Web3(HTTPProvider('http://localhost:8545'))
>>> web3.eth.blockNumber
4000000或者是基于IPC的连接
>>> web3 = Web3(IPCProvider())请注意,每个进程只应创建一个RPCProvider,因为它回收进程和Ethereum节点之间的底层TCP/IP网络连接。
https://ethereum.stackexchange.com/questions/27876
复制相似问题