0

I've launched a geth client over IPC:

geth --dev --allow-insecure-unlock --ipcpath ipc://$HOME/Library/Ethereum/geth.ipc

And trying to connect using a Web3 IPC provider:

my_provider = Web3.IPCProvider('ipc://$HOME/Library/Ethereum/geth.ipc')

which doesn't work with the following error:

FileNotFoundError: [Errno 2] No such file or directory

Also I don't see a geth.ipc file in my Ethereum folder after the geth client is launched.

1

The problem is that you need to specify the path as follows:

$ geth --dev --allow-insecure-unlock --ipcpath $HOME/Library/Ethereum/geth.ipc

Then you can find your geth.ipc file:

$ ls Library/Ethereum/
geth.ipc

Web3.py

>>> from web3 import Web3
>>> my_provider = Web3.IPCProvider("$HOME/Library/Ethereum/geth.ipc")
>>> my_provider
<web3.providers.ipc.IPCProvider object at 0x7f32f633bfd0>

From the docs:

  --ipcpath     Filename for IPC socket/pipe within the datadir (explicit paths escape it)
  • 1
    Just a small note, $HOME didn't work for me in web3, but ~ did. There was a PR that uses pathlib to resolve home directories using ~. – Peteris Sep 2 at 13:21

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.