Easyocr python import error after changing to exe

59 views Asked by At

I have a python code that uses easyocr to read text from a png image, in pycharm it works fine but when I change it to exe using

pyinstaller -F asd.py --collect-all easyocr

*this is a solution from github

I cannot import the necessary libraries, how to solve this? There may also be another library that you know to recognize text in an image (it is on a uniform background, so it may be simple), but not the pytesseract type which needs an external application installed on the device to work

code 1:

print("import1")
import time
print("import2")
from pynput import keyboard
print("import3")
import easyocr
print("import4")
import threading, datetime, os, gzip, psutil, pyautogui
print("import5")
from PIL import ImageGrab

error 1:

import1
import2
import3
torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
torch\_jit_internal.py:857: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x0000017E5EDE7F60>.
  warnings.warn(
torch\_jit_internal.py:857: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x0000017E5EE08A40>.
  warnings.warn(
Cannot load imports from non-existent stub 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI24122\\skimage\\exposure\\__init__.pyi'

code 2:

print("import1")
import time
print("import2")
from pynput import keyboard
import libpng, libjpeg
print("import3")
import torchvision.io
print("import4")
import skimage.exposure
print("import5")
import threading, datetime, os, gzip, psutil, pyautogui, easyocr
print("import6")
from PIL import ImageGrab

error 2:

import1
import2
import3
torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
torch\_jit_internal.py:857: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x0000026148901760>.
  warnings.warn(
torch\_jit_internal.py:857: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x0000026148902200>.
  warnings.warn(

import4
Cannot load imports from non-existent stub 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI43802\\skimage\\exposure\\__init__.pyi'
0

There are 0 answers