Auto-py-to-exe not packaging all the references properly

38 Views Asked by At

I am using Auto-py-to-exe to build python exe for distribution. My python code is running perfectly fine when running from IDE. When, I try to use Auto-py-to-exe to convert it to executable then it is properly creating output file .exe However, when running it is giving below error of missing package.

Traceback (most recent call last):
  File "main.py", line 91, in start_login
  File "main.py", line 115, in minimize_to_tray
  File "pdfextract.py", line 31, in extract_pdf
  File "pdfextract.py", line 50, in ocr_with_word_dimensions
  File "pdfplumber\page.py", line 572, in to_image
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "pdfplumber\display.py", line 7, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "pypdfium2\__init__.py", line 4, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "pypdfium2\_library_scope.py", line 6, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "pypdfium2\raw.py", line 5, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "pypdfium2_raw\__init__.py", line 5, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "pypdfium2_raw\bindings.py", line 53, in <module>
  File "pypdfium2_raw\bindings.py", line 44, in _register_library
  File "pypdfium2_raw\bindings.py", line 37, in _find_library
ImportError: Could not find library 'pdfium' (dirs=['.'], search_sys=False)

My code is importing package:

import pdfplumber
import pytesseract
from pytesseract import Output
from sap import SAP
import sys

if getattr(sys, 'frozen', False):
    _path = os.path.join(sys._MEIPASS, './tresseract/tesseract.exe')
    print(_path)
    pytesseract.pytesseract.tesseract_cmd = _path
    # the .exe will look here
else:
    pytesseract.pytesseract.tesseract_cmd = r"C:/Program Files/Tesseract-OCR/tesseract.exe"

I have already installed, pdfium separately in my virtual environment. Also, while compiling with Auto-py-to-exe I am adding it in --hiddenimport and also adding pdfplumber. The pdfplumber is using pdfium package.

I am clueless what to be done further to make it workable.

0

There are 0 best solutions below