ethereum / eth-account

Account abstraction library for web3.py
http://eth-account.readthedocs.io/
MIT License
269 stars 156 forks source link

"detect_language" throwing erroneous error only when compiled via pyinstaller #218

Closed Wretnuh closed 7 months ago

Wretnuh commented 1 year ago

If this is a bug report, please fill in the following sections. If this is a feature request, delete and describe what you would like with examples.

What was wrong?

After compiling via pyinstaller, the below python code would not work. It throws this error, which is found in "detect_language": "Language not detected for word(s): face business large tissue print box fix maple arena help critic border".

Code that produced the error

` from eth_account import Account

try: mnemonic_words = ('face', 'business', 'large', 'tissue', 'print', 'box', 'fix', 'maple', 'arena', 'help', 'critic', 'border')

mnemonic_string = ' '.join(mnemonic_words)
Account.enable_unaudited_hdwallet_features()
acct = Account.from_mnemonic(str(mnemonic_string))

public_address = acct.address

print('working')
print(public_address)
print(mnemonic_string)
input('wait')

except Exception as exception: print('failed') print(exception) input('wait') `

Full error output

Since this error is only reproducible when compiled, this is the extent of the error I am getting: "Language not detected for word(s): face business large tissue print box fix maple arena help critic border".

Environment

# run this:
$ python -m eth_utils

# then copy the output here:
Python version:
3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]

Operating System: Windows-10-10.0.20348-SP0

pip freeze result:
aiohttp==3.8.3
aiosignal==1.3.1
altgraph==0.17.3
async-generator==1.10
async-timeout==4.0.2
attrs==22.2.0
base58==2.1.1
beautifulsoup4==4.11.1
bitarray==2.6.2
bs4==0.0.1
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==2.1.1
cytoolz==0.12.1
eth-abi==4.0.0b2
eth-account==0.8.0
eth-hash==0.5.1
eth-keyfile==0.6.0
eth-keys==0.4.0
eth-rlp==0.3.0
eth-typing==3.2.0
eth-utils==2.1.0
frozenlist==1.3.3
h11==0.14.0
hexbytes==0.3.0
idna==3.4
ipfshttpclient==0.8.0a2
jsonschema==4.17.3
lru-dict==1.1.8
multiaddr==0.0.9
multidict==6.0.4
netaddr==0.8.0
outcome==1.2.0
parsimonious==0.9.0
pefile==2023.2.7
protobuf==4.21.12
pybit==2.4.1
pycparser==2.21
pycryptodome==3.16.0
pyinstaller==5.8.0
pyinstaller-hooks-contrib==2023.0
pyrsistent==0.19.3
PySocks==1.7.1
pywin32==305
pywin32-ctypes==0.2.0
regex==2022.10.31
requests==2.28.2
rlp==3.0.0
selenium==4.7.2
six==1.16.0
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve==2.3.2.post1
toolz==0.12.0
trio==0.22.0
trio-websocket==0.9.2
urllib3==1.26.14
varint==1.0.2
web3 @ git+https://github.com/ethereum/web3.py.git@d7861014f1628496d96c1777dfbedd56bd2fb591
websocket-client==1.5.1
websockets==10.4
wsproto==1.2.0
yarl==1.8.2

How can it be fixed?

Not able to find a fix

kclowes commented 1 year ago

Python 3.11 support hasn't been released yet, so the first thing I would try is downgrading to Python 3.10 and see if that fixes things. Let me know if it doesn't fix it and I can take a deeper look.

JustRomanBZK commented 1 year ago

Compilation does not want to pack dictionaries. It is possible to force the compiler to pack dictionaries, but I decided to just keep the wordlist folder with the necessary dictionaries next to the .exe file. if not getattr(sys, 'frozen', False): WORDLIST_DIR = Path(__file__).parent / "wordlist" else: WORDLIST_DIR = Path(os.path.dirname(sys.executable)) / 'wordlist'

kclowes commented 7 months ago

This just came up in our discord. Thanks for the response to this, @JustRomanBZK. It looks like if you're using Pyinstaller, you need to tell it where to find the files. Found in this SO answer. Closing because I don't think there is anything for us to do here.