Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 ImportError: cannot import name 'getargspec' from 'inspect' #2704

Closed
welikethecoin opened this issue Nov 1, 2022 · 16 comments
Closed

Comments

@welikethecoin
Copy link

  • Version: Fresh install from pip
  • Python: 3.11
  • OS: OSX Ventura 13.0 - 2021 Apple Macbook Pro 13 - M1 Chip 16gb Memory
  • pip freeze output
aiodns==3.0.0
aiohttp==3.8.3
aiosignal==1.2.0
anyio==3.6.2
async-timeout==4.0.2
attrs==22.1.0
base58==2.1.1
bitarray==2.6.0
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
cytoolz==0.12.0
eth-abi==2.2.0
eth-account==0.5.9
eth-hash==0.5.0
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
frozenlist==1.3.1
h11==0.12.0
hexbytes==0.3.0
httpcore==0.15.0
httpx==0.23.0
idna==3.4
ipfshttpclient==0.8.0a2
jsonschema==4.16.0
lru-dict==1.1.8
multiaddr==0.0.9
multidict==6.0.2
netaddr==0.8.0
numpy==1.23.4
pandas==1.5.1
parsimonious==0.8.1
protobuf==3.19.5
pycares==4.2.2
pycparser==2.21
pycryptodome==3.15.0
pyrsistent==0.18.1
python-dateutil==2.8.2
pytz==2022.5
requests==2.28.1
rfc3986==1.5.0
rlp==2.0.1
six==1.16.0
sniffio==1.3.0
toolz==0.12.0
urllib3==1.26.12
varint==1.0.2
web3==5.31.1
websocket-client==1.4.1
websockets==9.1
wsaccel==0.6.4
yarl==1.8.1

What was wrong?

Failed to import module in Python 3.11

How can it be fixed?

Unsure. Included full logs below


>>> from web3 import Web3

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/web3/__init__.py", line 6, in <module>
    from eth_account import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_account/__init__.py", line 1, in <module>
    from eth_account.account import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_account/account.py", line 59, in <module>
    from eth_account.messages import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_account/messages.py", line 26, in <module>
    from eth_account._utils.structured_data.hashing import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_account/_utils/structured_data/hashing.py", line 9, in <module>
    from eth_abi import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_abi/__init__.py", line 6, in <module>
    from eth_abi.abi import (  # NOQA
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_abi/abi.py", line 1, in <module>
    from eth_abi.codec import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_abi/codec.py", line 16, in <module>
    from eth_abi.decoding import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_abi/decoding.py", line 14, in <module>
    from eth_abi.base import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_abi/base.py", line 7, in <module>
    from .grammar import (
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/eth_abi/grammar.py", line 4, in <module>
    import parsimonious
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/parsimonious/__init__.py", line 9, in <module>
    from parsimonious.grammar import Grammar, TokenGrammar
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/parsimonious/grammar.py", line 14, in <module>
    from parsimonious.expressions import (Literal, Regex, Sequence, OneOf,
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wise/PycharmProjects/headline-trader/venv/lib/python3.11/site-packages/parsimonious/expressions.py", line 9, in <module>
    from inspect import getargspec
ImportError: cannot import name 'getargspec' from 'inspect' (/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py)
@sramasub
Copy link

sramasub commented Nov 2, 2022

I face the same error. Unable to import from web3 and gives this error message. Using python 3.11 as well.

@pacrob
Copy link
Contributor

pacrob commented Nov 2, 2022

3.11 support is on the way with PR #2699, give us a bit to get that wrapped up and merged. Please reopen if you're still having problems after it's officially supported.

@pacrob pacrob closed this as completed Nov 2, 2022
@khrousdevil
Copy link

try to downgrade to a lower python version, i used python 3.7.6 to avoid the problem

@wiseman2
Copy link

wiseman2 commented Dec 1, 2022

solved.... goto => site-packages/parsimonious/expressions.py and change import line to say..... from inspect import getfullargspec

@wiseman2
Copy link

wiseman2 commented Dec 1, 2022

if you look in the python 3.9 version of inspect search for=> getargspec
It says that it's depreciated and to use getfullargspec instead.

@loichau1997
Copy link

solved.... goto => site-packages/parsimonious/expressions.py and change import line to say..... from inspect import getfullargspec

This is working

@thegamebegins25
Copy link

If you installed web3.py through pip, it still won't work while the update is being approved. Run pip uninstall web3 to uninstall the old version, and run pip install git+https://github.com/ethereum/web3.py.git to install the new version off GitHub.

@0xACE3
Copy link

0xACE3 commented Jan 2, 2023

If you installed web3.py through pip, it still won't work while the update is being approved. Run pip uninstall web3 to uninstall the old version, and run pip install git+https://github.com/ethereum/web3.py.git to install the new version off GitHub.

Now this works for me. Thanks :-)

@amfredfred
Copy link

This works for me too, thanks man !!!!

@0xPoon
Copy link

0xPoon commented Mar 3, 2023

solved.... goto => site-packages/parsimonious/expressions.py and change import line to say..... from inspect import getfullargspec

Hi, if I don't have "site-packages/parsimonious/expressions.py" I would have to install the parsimonious package first prior to doing this?

*UPDATE - nevermind I have figured it out

@welikethecoin
Copy link
Author

Amazing. Thanks for all your help!

@P4RASTOO
Copy link

Try uninstalling web3 using pip uninstall web3.py and install the latest version from github using pip install git+https://github.com/ethereum/web3.py.git

@shifenhutu
Copy link

same here ,
but when i installed the latest version, then it works for me

pip uninstall web3
pip install web3

@Pankajkchhabra
Copy link

look at the error file and find "from inspect import ArgSpec", replace with from inspect import getfullargspec
It worked

@PaveenPaul
Copy link

add this line for python 3.11
from inspect import getfullargspec as getargspec

@julgoncon
Copy link

solved.... goto => site-packages/parsimonious/expressions.py and change import line to say..... from inspect import getfullargspec

still working... 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests