ethereum / eth-abi

Ethereum ABI utilities for python
MIT License
247 stars 269 forks source link

ImportError: cannot import name 'encode' from 'eth_abi' #170

Closed q9f closed 2 years ago

q9f commented 2 years ago

What was wrong?

The docs: https://eth-abi.readthedocs.io/en/latest/encoding.html

Suggest to import encode from eth_abi which is apparently not available.

Code that produced the error

from eth_abi import encode

Full error output

>>> from eth_abi import encode
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'encode' from 'eth_abi' (/home/user/.local/lib/python3.10/site-packages/eth_abi/__init__.py)

Environment

❯ python -m eth_utils
Python version:
3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0]

Operating System: Linux-5.17.7-arch1-1-x86_64-with-glibc2.35

pip freeze result:
appdirs==1.4.4
btrfsutil==5.17
CacheControl==0.12.6
ceph==1.0.0
ceph-volume==1.0.0
cephfs==2.0.0
cephfs-shell==0.0.1
cffi==1.15.0
chardet==4.0.0
colorama==0.4.4
configobj==5.1.0.dev0
contextlib2==0.6.0.post1
cryptography==37.0.0
cytoolz==0.11.2
decorator==5.1.1
distlib==0.3.4
distro==1.7.0
dnspython==2.2.1
eth-abi==3.0.0
eth-hash==0.3.2
eth-typing==3.0.0
eth-utils==2.0.0
filelock==3.4.2
GDAL==3.4.0
html5lib==1.1
idna==3.3
importlib-metadata==4.8.1
Jinja2==3.0.3
louis==3.21.0
Markdown==3.3.7
MarkupSafe==2.1.1
meld==3.20.4
meson==0.62.1
more-itertools==8.12.0
msgpack==1.0.3
netsnmp-python==1.0a1
numpy==1.22.3
ordered-set==4.0.2
OWSLib==0.25.0
packaging==21.3
parsimonious==0.8.1
pep517==0.12.0
pikaur==1.10.1
platformdirs==2.5.0
ply==3.11
powerline-status==2.8.2
progress==1.6
protontricks==1.8.1
psutil==5.9.0
psycopg2==2.9.3
pyalpm==0.10.6
pycairo==1.21.0
pycparser==2.21
Pygments==2.12.0
PyGObject==3.42.1
pyOpenSSL==22.0.0
pyparsing==3.0.8
pyproj==3.0.1
PyQt3D==5.15.5
PyQt5==5.15.6
PyQt5-sip==12.10.1
PyQtChart==5.15.5
PyQtDataVisualization==5.15.5
PyQtNetworkAuth==5.15.5
PyQtPurchasing==5.15.5
PyQtWebEngine==5.15.5
pyte==0.8.0
python-dateutil==2.8.2
pytz==2022.1
PyYAML==6.0
QScintilla==2.13.3
rados==2.0.0
rbd==2.0.0
requests==2.27.1
resolvelib==0.5.5
retrying==1.3.3
rgw==2.0.0
six==1.16.0
terminator==2.1.1
thefuck==3.32
toml==0.10.2
tomli==2.0.1
toolz==0.11.2
urllib3==1.26.9
validate==5.1.0.dev0
vdf==3.4
virtualenv==20.11.0
wcwidth==0.2.5
webencodings==0.5.1
zipp==3.8.0
kclowes commented 2 years ago

Sorry for the confusion! It looks like you're looking at the 'latest' version of the docs which builds from master. We consolidated encode_single and encode_abi into one encode method, between now and the last release. You can either install eth_abi from master or you can use encode_single or encode_abi with v3.0.0. Here's a link to the stable version of the docs: https://eth-abi.readthedocs.io/en/stable/encoding.html if you want to use encode_single or encode_abi.

q9f commented 2 years ago

Thank you, that works for me!