ipfsapi ipfshttpclient issue with Pyinstaller

23 views
Skip to first unread message

Matias Salimbene

unread,
Oct 29, 2024, 2:32:24 PM10/29/24
to PyInstaller
I'm running a simple script that downloads and uploads files from an IPFS node using ipfsapi. Everything works fine. 

But when running with Pyinstaller ( I use the --onefile option, but same thing happens with default settings), I get the following err:

Traceback (most recent call last):
File "multiaddr/transforms.py", line 66, in string_iter
File "multiaddr/codecs/__init__.py", line 23, in codec_by_name
...
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'multiaddr.codecs.idna'

The above exception was the direct cause of the following exception:
Traceback (most recent call last):

File "apt.py", line 9, in <module>
import ipfsapi
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

multiaddr.exceptions.StringParseError: Invalid MultiAddr '/dns/localhost/tcp/5001/http' protocol dns: Unknown Protocol

[PYI-29889:ERROR] Failed to execute script 'apt' due to unhandled exception!

I've tried using a hook for force miltiaddr loading, I've tried with ipfshttpclient (newer version of ipfsapi) but always get the exact same error. But it fails only when running with Pyinstaller, If I run my script with python, it just works.

Something odd I found is that I print a message at the very start of the script, that with Pyinstaller doesn't get printed so it seems the failure comes even before my script is executed. As if its loading the modules before running the script, and as part of loading is trying to connect to /dns/localhost/tcp/5001/http, but that will always fails, I don't have a node running on localhost. 

Any ideas?

Thanks

bwoodsend

unread,
Nov 1, 2024, 1:07:08 PM11/1/24
to PyInstaller

Add --hiddenimport=multiaddr.codecs.idna to your build command?

Matias Salimbene

unread,
Nov 4, 2024, 10:16:38 AM11/4/24
to PyInstaller
After I added that to the build command I got a simmilar error but referencing another library, I added that as well, and now works. I ended up running it like this:

pyinstaller -F --hiddenimport=multiaddr.codecs.idna --hiddenimport=multiaddr.codecs.uint16be --clean apt.py

Thank you!
Reply all
Reply to author
Forward
0 new messages