0

I used web3.py to create a program, and turned it into an exe with pyinstaller, but now I am getting this error when I try to run the exe:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "web3\__init__.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "web3\main.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ens\__init__.py", line 3, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ens\async_ens.py", line 35, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ens\base_ens.py", line 18, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ens\utils.py", line 39, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ens\_normalization.py", line 57, in <module>
  FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\SELCUK~1\\AppData\\Local\\Temp\\_MEI166402\\ens\\specs\\normalization_spec.json'

The given directory path is wrong, so it's normal that this gives an error, but I have no way of fixing this as this is a problem from inside the web3 module. Has anyone ever came across this error?

1
  • Also wanted to add, the code works fine when not compiled into an exe so it's not a code related problem. It's a compilation related problem. Commented Jul 19, 2023 at 13:35

3 Answers 3

1

use web3==5.31.4

not use web3>=6.*

1
  • Thanks, it worked. Commented Jul 20, 2023 at 10:15
1

Version 6.6.0 had a problem with the necessary json files not being included. If you specify 6.6.1 you should be fine. Support for v5 is due to stop in August.

0

pyinstaller needs a manual addition utilizing the --add-data flag. This question has been answered before for similar issues:

https://stackoverflow.com/questions/62017384/adding-json-files-to-an-exe-file-using-pyinstaller

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.