Skip to content

Error importing Uniswap with the latest version of web3.py #322

Closed

Description

@arjunaskykok

Describe the bug

>>> from uniswap import Uniswap
from web3.contract import Contract, ContractFunction
ImportError: cannot import name 'ContractFunction' from 'web3.contract'

To Reproduce

$ python3.11 -m venv .venv
$ source .venv/bin/activate
(.venv) $ pip install git+https://github.com/ethereum/web3.py.git
(.venv) $ pip install uniswap-python
(.venv) $ python
Python 3.11.2 (main, Feb  8 2023, 14:49:24) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from uniswap import Uniswap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/arjuna/.../review_uniswap_python/.venv/lib/python3.11/site-packages/uniswap/__init__.py", line 2, in <module>
    from .uniswap import Uniswap, _str_to_addr
  File "/home/arjuna/.../review_uniswap_python/.venv/lib/python3.11/site-packages/uniswap/uniswap.py", line 11, in <module>
    from web3.contract import Contract, ContractFunction
ImportError: cannot import name 'ContractFunction' from 'web3.contract' (/home/arjuna/.../review_uniswap_python/.venv/lib/python3.11/site-packages/web3/contract/__init__.py)
>>> from web3.contract import ContractFunction
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'ContractFunction' from 'web3.contract' (/home/arjuna/.../review_uniswap_python/.venv/lib/python3.11/site-packages/web3/contract/__init__.py)
>>> from web3.contract.contract import ContractFunction
>>>

Expected behavior
We should be able to import Uniswap with the latest version of web3.

Additional context
The reason I installed web3.py from GitHub repo is Python3.11 doesn't work with web3.py from pip.

ImportError: cannot import name 'getargspec' from 'inspect' (/usr/lib/python3.11/inspect.py)

Activity

  1. ErikBjare commented on Mar 6, 2023

    @ErikBjare
    Member

    Working on a fix in #320

  2. Lodimup commented on Mar 24, 2023

    @Lodimup

    web3 = "5.24" works

  3. Moka51 commented on Mar 26, 2023

    @Moka51

    Any update about this? Thanks in advance team!

  4. DavidZQuant commented on Mar 27, 2023

    @DavidZQuant

    Running into the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions