Issue converting python script with pyinstaller. Import error: Incompatible library

Viewed 277

I am relatively new to programming and I am using macOS Catalina 10.15.4 python 3.7 and pyinstaller3.6 to convert my python script to an executable. I manage to convert the script to an executable but when I click on it I get the following error:

issue:Traceback (most recent call last):
  File "QC.py", line 2, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "cv2/__init__.py", line 5, in <module>
ImportError: dlopen(/Users/kapten42/Desktop/OCR/QA/dist/QC/cv2/cv2.cpython-37m-darwin.so, 2): Library not loaded: @loader_path/libpng16.16.dylib
  Referenced from: /Users/kapten42/Desktop/OCR/QA/dist/QC/libfreetype.6.dylib
  Reason: Incompatible library version: libfreetype.6.dylib requires version 54.0.0 or later, but libpng16.16.dylib provides version 38.0.0
[35604] Failed to execute script QC

I installed most of my packages using pip3 except for tesseract which I had to install using brew. I have been searching everywhere and really stumped with this one. I used brew to update libpng but the it didn't change anything. Below is the list of imports made at the top of my code. I am really stuck so any advice is greatly appreciated

from PIL import Image
import cv2
from skimage.filters import threshold_local
from skimage import io
import csv
import pytesseract
import re
import imutils
import numpy as np
from datetime import datetime
from spellchecker import SpellChecker
import json
import tempfile
import requests
import os
from pdf2image import convert_from_path
from dateutil.relativedelta import relativedelta
1 Answers

So I found a solution to the problem. Pyinstaller was pulling the wrong libpng16.16.dylib into the dist folder that was created. I used

brew install libpng

to get the latest version and then went to the folder

usr/local/cellar/libpng/1.6.37/lib 

and copied libpng16.16.dylib and moved it to the dist folder and that resolved the issue.

Related