dydxprotocol / dydx-v3-python

Python client for dYdX (API v3)
Apache License 2.0
306 stars 176 forks source link

ImportError: cannot import name 'getargspec' from 'inspect' #209

Open StayFoolisj opened 1 year ago

StayFoolisj commented 1 year ago

Having some issues trying to run the basic examples. The error is an importError from inspect.getargspec(). A quick search shows that it was depreciated with Python 3, and deleted with 3.11. Raising an issue since you wrote that this repo is tested against 3.11.

Specs / Versions:

Macbook M1 ARM64
Python 3.11.3
dydx-v3-python     2.0.1
ecdsa              0.18.0
eth-abi            2.2.0
eth-account        0.5.9
eth-hash           0.5.2
eth-keyfile        0.5.1
eth-keys           0.3.4
eth-rlp            0.2.1
eth-typing         2.3.0
eth-utils          1.9.5

When I try to run the test example in the README.md:

from dydx3 import Client
from web3 import Web3

#
# Access public API endpoints.
#
public_client = Client(
    host='http://localhost:8080',
)
public_client.public.get_markets()

I get the following error:

Traceback (most recent call last):
  File "/code/trade_repo/src/trade_lab.py", line 1, in <module>
    from dydx3 import Client
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/dydx3/__init__.py", line 1, in <module>
    from dydx3.dydx_client import Client
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/dydx3/dydx_client.py", line 1, in <module>
    from web3 import Web3
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/web3/__init__.py", line 6, in <module>
    from eth_account import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_account/__init__.py", line 1, in <module>
    from eth_account.account import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_account/account.py", line 59, in <module>
    from eth_account.messages import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_account/messages.py", line 26, in <module>
    from eth_account._utils.structured_data.hashing import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_account/_utils/structured_data/hashing.py", line 9, in <module>
    from eth_abi import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_abi/__init__.py", line 6, in <module>
    from eth_abi.abi import (  # NOQA
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_abi/abi.py", line 1, in <module>
    from eth_abi.codec import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_abi/codec.py", line 16, in <module>
    from eth_abi.decoding import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_abi/decoding.py", line 14, in <module>
    from eth_abi.base import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_abi/base.py", line 7, in <module>
    from .grammar import (
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/eth_abi/grammar.py", line 4, in <module>
    import parsimonious
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/parsimonious/__init__.py", line 9, in <module>
    from parsimonious.grammar import Grammar, TokenGrammar
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/parsimonious/grammar.py", line 14, in <module>
    from parsimonious.expressions import (Literal, Regex, Sequence, OneOf,
  File "/code/trade_repo/.venv/lib/python3.11/site-packages/parsimonious/expressions.py", line 9, in <module>
    from inspect import getargspec
ImportError: cannot import name 'getargspec' from 'inspect' (/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py)
HydeSong commented 1 year ago

@StayFoolisj I get the same error. Have you solved it?

Otnicka1 commented 11 months ago

workaround : Edit this file : image Replace from inspect import getargspec ==> from inspect import getfullargspec

sirEven commented 9 months ago

Getting same error have you solved it?

FWIW, you might wanna try my PR. I specifically mentioned this issue here, because i try to solve these errors there - which for now works fine on my end. I am using Python 3.11.4. Sepolia migration has been merged in already.