Pyinstaller error running script with pyzmq dependency

Viewed 1187

This is my first StackOverflow post!

I am running into issues creating a pyinstaller(v4.2) executable with a pyzmq (v22.0.2) dependency. I created an executable by running "pyinstaller main.py". The dist folder was created without errors but when I run the executable in the terminal, I see the error in quotes below.

I did a search for this kind of issue on StackOverflow and pyinstaller's documentation with no match to my exact problem. I saw mention of a .spec file for what seemed like similar issues, though I am not sure if this is the way to go since I am unclear what pyzmq.libs\.load_order is.

Does anyone know how to overcome this error or have good leads on what I may try?

"C:\Users\[redacted path]\dist\main>main.exe
Traceback (most recent call last):
  File "main.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
  File "zmq\__init__.py", line 19, in <module>
  File "zmq\__init__.py", line 13, in _delvewheel_init_patch_0_0_9
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\[redacted path]\\dist\\main\\pyzmq.libs\\.load_order'
[4408] Failed to execute script main

C:\Users\[redacted path]\dist\main>"
2 Answers

I had the same problem and found this solution Downgrade to 21.0.0 using pip install pyzmq==21.0.0 then you can run pyinstaller again and it will run perfectly fine.

Find a folder called 'pyzmq.libs' in your <local-python-path>\Lib\site-packages.

For example, I'm using Miniconda3 here, so I got this at C:\\Users\MyPC\Miniconda3\envs\my_env\Lib\site-packages

Then, copy this folder to your C:\\Users\\[redacted path]\\dist\\main folder, and re-try the executable.

Related