ethereum / eth-utils

Utility functions for working with ethereum related codebases.
https://eth-utils.readthedocs.io/en/latest/
MIT License
312 stars 150 forks source link

ModuleNotFoundError: No module named 'eth_hash' when trying to import this with poetry #218

Closed flokli closed 2 years ago

flokli commented 2 years ago

What was wrong?

I added eth_utils (trough eth_abi) to a python project, which uses poetry to manage dependencies.

It seems poetry doesn't pick up eth_hash as a dependency of eth_utils:

Code that produced the error

poetry init
poetry add eth_abi
# create code with `from eth_abi import encode_abi`
poetry install
# run your code

Output:

      File "/nix/store/bwz0jq2hdgf1bavsssmvcjwplnqg8hcr-python3.10-eth-abi-3.0.0/lib/python3.10/site-packages/eth_abi/__init__.py", line 3, in <module>
        from eth_abi.abi import (  # NOQA
      File "/nix/store/bwz0jq2hdgf1bavsssmvcjwplnqg8hcr-python3.10-eth-abi-3.0.0/lib/python3.10/site-packages/eth_abi/abi.py", line 1, in <module>
        from eth_abi.codec import (
      File "/nix/store/bwz0jq2hdgf1bavsssmvcjwplnqg8hcr-python3.10-eth-abi-3.0.0/lib/python3.10/site-packages/eth_abi/codec.py", line 11, in <module>
        from eth_utils import (
      File "/nix/store/ssvq91kw8zablrxw1qhv2nim52f3wlz7-python3.10-eth-utils-2.0.0/lib/python3.10/site-packages/eth_utils/__init__.py", line 6, in <module>
        from .abi import (  # noqa: F401
      File "/nix/store/ssvq91kw8zablrxw1qhv2nim52f3wlz7-python3.10-eth-utils-2.0.0/lib/python3.10/site-packages/eth_utils/abi.py", line 3, in <module>
        from .crypto import keccak
      File "/nix/store/ssvq91kw8zablrxw1qhv2nim52f3wlz7-python3.10-eth-utils-2.0.0/lib/python3.10/site-packages/eth_utils/crypto.py", line 3, in <module>
        from eth_hash.auto import keccak as keccak_256
    ModuleNotFoundError: No module named 'eth_hash'

Expected Result

I assume eth-utils would need to list its dependencies in pyproject.toml.

Shivam-Shrivastav commented 2 years ago

Install eth-hash 0.3.2 using

pip install eth-hash

It might solve the problem

flokli commented 2 years ago

Yes, manually adding it to my project works. However, if eth-utils depends on eth-hash, it should declare this in its dependencies, no?

carver commented 2 years ago

eth-utils does specify eth-hash as a dependency. Have you tried using a fresh virtualenv with pip install eth-utils?

Closing as not a bug unless there's a problem with basic pip (will consider it a poetry bug).