cx_Freeze: Executable with pytesseract fails on other PC












0















I've made an executable file from my Python - OCR program (import pytesseract) using cx_Freeze. The resulting .exe works fine on my own machine. To test the program I made a zip-folder and shared it with some friends and colleagues on a share point.
Now there is the following problem with the executable. It seems like pytesseract isn't included in the executable / zip-folder.



Here is the ErrorLog:



The file is not a PNG-file:  20181108 Kontaktanzeigen-Er_sucht_sie.jpg
The file is not a PNG-file: 20181108 Kontaktanzeigen-Sie_sucht_ihn.jpg
The file is not a PNG-file: 20181108 Language family tree.jpg
The file is not a PNG-file: 20181108 relax.jpg
The file is not a PNG-file: 20181109 Essen wie Gott am Südpol S1.JPG
The file is not a PNG-file: 20181109 Fahrzeugschein1.jpg
The file is not a PNG-file: 20181112 sie_sind_alle_so_dumm.jpg
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 67, in img_to_text
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

Exception in thread Thread-2:
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 73, in img_to_text1
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path


The first lines are absolute clear. I've found some ideas to modify setup.py to include all imports in the executable created by cx_Freeze. Here is the latest version.



from cx_Freeze import setup, Executable
import os.path

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

additional_mods = ['numpy.core._methods', 'numpy.lib.format']
additional_files = [os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll')]

options = {
'build_exe': {'include_files': additional_files, 'includes': additional_mods}
}

setup(options = options,
name = "main" ,
version = "0.1" ,
description = "" ,
executables = [Executable("main.py")])









share|improve this question





























    0















    I've made an executable file from my Python - OCR program (import pytesseract) using cx_Freeze. The resulting .exe works fine on my own machine. To test the program I made a zip-folder and shared it with some friends and colleagues on a share point.
    Now there is the following problem with the executable. It seems like pytesseract isn't included in the executable / zip-folder.



    Here is the ErrorLog:



    The file is not a PNG-file:  20181108 Kontaktanzeigen-Er_sucht_sie.jpg
    The file is not a PNG-file: 20181108 Kontaktanzeigen-Sie_sucht_ihn.jpg
    The file is not a PNG-file: 20181108 Language family tree.jpg
    The file is not a PNG-file: 20181108 relax.jpg
    The file is not a PNG-file: 20181109 Essen wie Gott am Südpol S1.JPG
    The file is not a PNG-file: 20181109 Fahrzeugschein1.jpg
    The file is not a PNG-file: 20181112 sie_sind_alle_so_dumm.jpg
    Exception in thread Thread-3:
    Traceback (most recent call last):
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
    FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
    File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 67, in img_to_text
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
    pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

    Exception in thread Thread-2:
    Traceback (most recent call last):
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
    FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
    File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 73, in img_to_text1
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
    File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
    pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path


    The first lines are absolute clear. I've found some ideas to modify setup.py to include all imports in the executable created by cx_Freeze. Here is the latest version.



    from cx_Freeze import setup, Executable
    import os.path

    PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
    os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
    os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

    additional_mods = ['numpy.core._methods', 'numpy.lib.format']
    additional_files = [os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
    os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll')]

    options = {
    'build_exe': {'include_files': additional_files, 'includes': additional_mods}
    }

    setup(options = options,
    name = "main" ,
    version = "0.1" ,
    description = "" ,
    executables = [Executable("main.py")])









    share|improve this question



























      0












      0








      0








      I've made an executable file from my Python - OCR program (import pytesseract) using cx_Freeze. The resulting .exe works fine on my own machine. To test the program I made a zip-folder and shared it with some friends and colleagues on a share point.
      Now there is the following problem with the executable. It seems like pytesseract isn't included in the executable / zip-folder.



      Here is the ErrorLog:



      The file is not a PNG-file:  20181108 Kontaktanzeigen-Er_sucht_sie.jpg
      The file is not a PNG-file: 20181108 Kontaktanzeigen-Sie_sucht_ihn.jpg
      The file is not a PNG-file: 20181108 Language family tree.jpg
      The file is not a PNG-file: 20181108 relax.jpg
      The file is not a PNG-file: 20181109 Essen wie Gott am Südpol S1.JPG
      The file is not a PNG-file: 20181109 Fahrzeugschein1.jpg
      The file is not a PNG-file: 20181112 sie_sind_alle_so_dumm.jpg
      Exception in thread Thread-3:
      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
      FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
      File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 67, in img_to_text
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
      pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

      Exception in thread Thread-2:
      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
      FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
      File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 73, in img_to_text1
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
      pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path


      The first lines are absolute clear. I've found some ideas to modify setup.py to include all imports in the executable created by cx_Freeze. Here is the latest version.



      from cx_Freeze import setup, Executable
      import os.path

      PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
      os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
      os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

      additional_mods = ['numpy.core._methods', 'numpy.lib.format']
      additional_files = [os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
      os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll')]

      options = {
      'build_exe': {'include_files': additional_files, 'includes': additional_mods}
      }

      setup(options = options,
      name = "main" ,
      version = "0.1" ,
      description = "" ,
      executables = [Executable("main.py")])









      share|improve this question
















      I've made an executable file from my Python - OCR program (import pytesseract) using cx_Freeze. The resulting .exe works fine on my own machine. To test the program I made a zip-folder and shared it with some friends and colleagues on a share point.
      Now there is the following problem with the executable. It seems like pytesseract isn't included in the executable / zip-folder.



      Here is the ErrorLog:



      The file is not a PNG-file:  20181108 Kontaktanzeigen-Er_sucht_sie.jpg
      The file is not a PNG-file: 20181108 Kontaktanzeigen-Sie_sucht_ihn.jpg
      The file is not a PNG-file: 20181108 Language family tree.jpg
      The file is not a PNG-file: 20181108 relax.jpg
      The file is not a PNG-file: 20181109 Essen wie Gott am Südpol S1.JPG
      The file is not a PNG-file: 20181109 Fahrzeugschein1.jpg
      The file is not a PNG-file: 20181112 sie_sind_alle_so_dumm.jpg
      Exception in thread Thread-3:
      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
      FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
      File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 67, in img_to_text
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
      pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

      Exception in thread Thread-2:
      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 170, in run_tesseract
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 707, in __init__
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsubprocess.py", line 992, in _execute_child
      FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 916, in _bootstrap_inner
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libthreading.py", line 864, in run
      File "C:UsersTFischerPycharmProjectsTest_ProjectOCR.py", line 73, in img_to_text1
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 294, in image_to_string
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 202, in run_and_get_output
      File "C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64libsite-packagespytesseractpytesseract.py", line 172, in run_tesseract
      pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path


      The first lines are absolute clear. I've found some ideas to modify setup.py to include all imports in the executable created by cx_Freeze. Here is the latest version.



      from cx_Freeze import setup, Executable
      import os.path

      PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
      os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
      os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

      additional_mods = ['numpy.core._methods', 'numpy.lib.format']
      additional_files = [os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
      os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll')]

      options = {
      'build_exe': {'include_files': additional_files, 'includes': additional_mods}
      }

      setup(options = options,
      name = "main" ,
      version = "0.1" ,
      description = "" ,
      executables = [Executable("main.py")])






      python executable cx-freeze pytesseract






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 28 '18 at 14:17









      jpeg

      1,0042919




      1,0042919










      asked Nov 28 '18 at 7:33









      tifi90tifi90

      938




      938
























          1 Answer
          1






          active

          oldest

          votes


















          1














          pytesseract is a wrapper for Google's Tesseract-OCR Engine. In order that pytesseractworks, the Tesseract-OCR engine needs to be installed and one must be able to invoke the tesseract command as tesseract (this means that the Tesseract-OCR installation directory needs to be in the PATH).



          I believe that pytesseract has been properly included in the executable but that the tesseract command does not work on the "other PC" (either Tesseract-OCR is not installed there or the Tesseract-OCR installation directory is not in the PATH there).



          You need to tell the owner of the "other PC" to install Tesseract-OCR and to check that it can be started with the command tesseract from any location.



          Another option would be to include the whole Tesseract-OCR installation directory in the frozen executable using the build_exeoption include_files (your variable additional_files) and to make sure that this included directory gets included in the PATH on the target PC, but this is probably not platform-independent and thus not recommended.






          share|improve this answer
























          • Since I want give the zip-Folder and some .png Files to students I want to keep it as simple as possible. I think I'll try the second idea. So if they put the unzipped file in C:OCR they must add C:OCR to their environmental variables or do they need to add the exact path to the sub-folder C:OCRbuild...tesseract?

            – tifi90
            Nov 28 '18 at 10:18











          • I'm pretty sure you need to add the exact path to the sub-folder in which tesseract.exe is found. You might even manage to do it dynamically in your main application using os.environ['PATH'] += os.pathsep + path_to_tesseract_folder with path_to_tesseract_folder computed on the basis of the main application location at runtime.

            – jpeg
            Nov 28 '18 at 12:14













          • I'm currently testing the changes. When I have results I'll let you know how it worked for me.

            – tifi90
            Nov 29 '18 at 15:51











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53514311%2fcx-freeze-executable-with-pytesseract-fails-on-other-pc%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          pytesseract is a wrapper for Google's Tesseract-OCR Engine. In order that pytesseractworks, the Tesseract-OCR engine needs to be installed and one must be able to invoke the tesseract command as tesseract (this means that the Tesseract-OCR installation directory needs to be in the PATH).



          I believe that pytesseract has been properly included in the executable but that the tesseract command does not work on the "other PC" (either Tesseract-OCR is not installed there or the Tesseract-OCR installation directory is not in the PATH there).



          You need to tell the owner of the "other PC" to install Tesseract-OCR and to check that it can be started with the command tesseract from any location.



          Another option would be to include the whole Tesseract-OCR installation directory in the frozen executable using the build_exeoption include_files (your variable additional_files) and to make sure that this included directory gets included in the PATH on the target PC, but this is probably not platform-independent and thus not recommended.






          share|improve this answer
























          • Since I want give the zip-Folder and some .png Files to students I want to keep it as simple as possible. I think I'll try the second idea. So if they put the unzipped file in C:OCR they must add C:OCR to their environmental variables or do they need to add the exact path to the sub-folder C:OCRbuild...tesseract?

            – tifi90
            Nov 28 '18 at 10:18











          • I'm pretty sure you need to add the exact path to the sub-folder in which tesseract.exe is found. You might even manage to do it dynamically in your main application using os.environ['PATH'] += os.pathsep + path_to_tesseract_folder with path_to_tesseract_folder computed on the basis of the main application location at runtime.

            – jpeg
            Nov 28 '18 at 12:14













          • I'm currently testing the changes. When I have results I'll let you know how it worked for me.

            – tifi90
            Nov 29 '18 at 15:51
















          1














          pytesseract is a wrapper for Google's Tesseract-OCR Engine. In order that pytesseractworks, the Tesseract-OCR engine needs to be installed and one must be able to invoke the tesseract command as tesseract (this means that the Tesseract-OCR installation directory needs to be in the PATH).



          I believe that pytesseract has been properly included in the executable but that the tesseract command does not work on the "other PC" (either Tesseract-OCR is not installed there or the Tesseract-OCR installation directory is not in the PATH there).



          You need to tell the owner of the "other PC" to install Tesseract-OCR and to check that it can be started with the command tesseract from any location.



          Another option would be to include the whole Tesseract-OCR installation directory in the frozen executable using the build_exeoption include_files (your variable additional_files) and to make sure that this included directory gets included in the PATH on the target PC, but this is probably not platform-independent and thus not recommended.






          share|improve this answer
























          • Since I want give the zip-Folder and some .png Files to students I want to keep it as simple as possible. I think I'll try the second idea. So if they put the unzipped file in C:OCR they must add C:OCR to their environmental variables or do they need to add the exact path to the sub-folder C:OCRbuild...tesseract?

            – tifi90
            Nov 28 '18 at 10:18











          • I'm pretty sure you need to add the exact path to the sub-folder in which tesseract.exe is found. You might even manage to do it dynamically in your main application using os.environ['PATH'] += os.pathsep + path_to_tesseract_folder with path_to_tesseract_folder computed on the basis of the main application location at runtime.

            – jpeg
            Nov 28 '18 at 12:14













          • I'm currently testing the changes. When I have results I'll let you know how it worked for me.

            – tifi90
            Nov 29 '18 at 15:51














          1












          1








          1







          pytesseract is a wrapper for Google's Tesseract-OCR Engine. In order that pytesseractworks, the Tesseract-OCR engine needs to be installed and one must be able to invoke the tesseract command as tesseract (this means that the Tesseract-OCR installation directory needs to be in the PATH).



          I believe that pytesseract has been properly included in the executable but that the tesseract command does not work on the "other PC" (either Tesseract-OCR is not installed there or the Tesseract-OCR installation directory is not in the PATH there).



          You need to tell the owner of the "other PC" to install Tesseract-OCR and to check that it can be started with the command tesseract from any location.



          Another option would be to include the whole Tesseract-OCR installation directory in the frozen executable using the build_exeoption include_files (your variable additional_files) and to make sure that this included directory gets included in the PATH on the target PC, but this is probably not platform-independent and thus not recommended.






          share|improve this answer













          pytesseract is a wrapper for Google's Tesseract-OCR Engine. In order that pytesseractworks, the Tesseract-OCR engine needs to be installed and one must be able to invoke the tesseract command as tesseract (this means that the Tesseract-OCR installation directory needs to be in the PATH).



          I believe that pytesseract has been properly included in the executable but that the tesseract command does not work on the "other PC" (either Tesseract-OCR is not installed there or the Tesseract-OCR installation directory is not in the PATH there).



          You need to tell the owner of the "other PC" to install Tesseract-OCR and to check that it can be started with the command tesseract from any location.



          Another option would be to include the whole Tesseract-OCR installation directory in the frozen executable using the build_exeoption include_files (your variable additional_files) and to make sure that this included directory gets included in the PATH on the target PC, but this is probably not platform-independent and thus not recommended.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 28 '18 at 9:44









          jpegjpeg

          1,0042919




          1,0042919













          • Since I want give the zip-Folder and some .png Files to students I want to keep it as simple as possible. I think I'll try the second idea. So if they put the unzipped file in C:OCR they must add C:OCR to their environmental variables or do they need to add the exact path to the sub-folder C:OCRbuild...tesseract?

            – tifi90
            Nov 28 '18 at 10:18











          • I'm pretty sure you need to add the exact path to the sub-folder in which tesseract.exe is found. You might even manage to do it dynamically in your main application using os.environ['PATH'] += os.pathsep + path_to_tesseract_folder with path_to_tesseract_folder computed on the basis of the main application location at runtime.

            – jpeg
            Nov 28 '18 at 12:14













          • I'm currently testing the changes. When I have results I'll let you know how it worked for me.

            – tifi90
            Nov 29 '18 at 15:51



















          • Since I want give the zip-Folder and some .png Files to students I want to keep it as simple as possible. I think I'll try the second idea. So if they put the unzipped file in C:OCR they must add C:OCR to their environmental variables or do they need to add the exact path to the sub-folder C:OCRbuild...tesseract?

            – tifi90
            Nov 28 '18 at 10:18











          • I'm pretty sure you need to add the exact path to the sub-folder in which tesseract.exe is found. You might even manage to do it dynamically in your main application using os.environ['PATH'] += os.pathsep + path_to_tesseract_folder with path_to_tesseract_folder computed on the basis of the main application location at runtime.

            – jpeg
            Nov 28 '18 at 12:14













          • I'm currently testing the changes. When I have results I'll let you know how it worked for me.

            – tifi90
            Nov 29 '18 at 15:51

















          Since I want give the zip-Folder and some .png Files to students I want to keep it as simple as possible. I think I'll try the second idea. So if they put the unzipped file in C:OCR they must add C:OCR to their environmental variables or do they need to add the exact path to the sub-folder C:OCRbuild...tesseract?

          – tifi90
          Nov 28 '18 at 10:18





          Since I want give the zip-Folder and some .png Files to students I want to keep it as simple as possible. I think I'll try the second idea. So if they put the unzipped file in C:OCR they must add C:OCR to their environmental variables or do they need to add the exact path to the sub-folder C:OCRbuild...tesseract?

          – tifi90
          Nov 28 '18 at 10:18













          I'm pretty sure you need to add the exact path to the sub-folder in which tesseract.exe is found. You might even manage to do it dynamically in your main application using os.environ['PATH'] += os.pathsep + path_to_tesseract_folder with path_to_tesseract_folder computed on the basis of the main application location at runtime.

          – jpeg
          Nov 28 '18 at 12:14







          I'm pretty sure you need to add the exact path to the sub-folder in which tesseract.exe is found. You might even manage to do it dynamically in your main application using os.environ['PATH'] += os.pathsep + path_to_tesseract_folder with path_to_tesseract_folder computed on the basis of the main application location at runtime.

          – jpeg
          Nov 28 '18 at 12:14















          I'm currently testing the changes. When I have results I'll let you know how it worked for me.

          – tifi90
          Nov 29 '18 at 15:51





          I'm currently testing the changes. When I have results I'll let you know how it worked for me.

          – tifi90
          Nov 29 '18 at 15:51




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53514311%2fcx-freeze-executable-with-pytesseract-fails-on-other-pc%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks