当前位置:网站首页>Problems and solutions of paddleocr packaging
Problems and solutions of paddleocr packaging
2022-07-27 01:38:00 【forward_ huan】
Situation 1
error
AssertionError: …/distutils/core.pyc
resolvent
reinstall setuptools Tools , The version I tried 58.0.0 Can solve this problem
pip install setuptools==58.0.0
Scenario two
error
When the package finishes running paddle\\fluid\\..\\libs problem
resolvent
The solution to a little violence is to attach importance to the virtual environment paddle And paddleocr Put it in the packed one exe In the same level directory .
When the above problems are solved , Next, there will be the following problems
ModuleNotFoundError: No module named 'shapely'
ModuleNotFoundError: No module named 'pyclipper'
ModuleNotFoundError: No module named 'skimage'
ModuleNotFoundError: No module named 'pywt'
ModuleNotFoundError: No module named 'imgaug'
ModuleNotFoundError: No module named 'imageio'
ModuleNotFoundError: No module named 'fasttext'
ModuleNotFoundError: No module named 'lmdb'
ModuleNotFoundError: No module named 'imghdr'
ModuleNotFoundError: No module named 'fasttext_pybind'
ImportError: cannot import name 'signal' from 'scipy' (...\scipy\__init__.pyc)
This is because paddleocr There are too many libraries to call , pyinstaller Not all modules are packaged , It's time to
We manually package these modules
How to put... When packing exe What about the same level directory , You need to use Pyinstaller Next --add-data 了
The following is a code example of encapsulation
def get_extra_params():
# Project root
root_path = get_root_path()
extra_data = [
("src\\res", "src\\res"),
("config", "config"),
("venv\\Lib\\site-packages\\Shapely.libs", "Shapely.libs"),
("venv\\Lib\\site-packages\\paddle", "paddle"),
("venv\\Lib\\site-packages\\paddleocr", "paddleocr"),
("venv\\Lib\\site-packages\\PIL", "PIL"),
("venv\\Lib\\site-packages\\pywt", "pywt"),
("venv\\Lib\\site-packages\\lmdb", "lmdb"),
("venv\\Lib\\site-packages\\shapely", "shapely"),
("venv\\Lib\\site-packages\\skimage", "skimage"),
("venv\\Lib\\site-packages\\pyclipper", "pyclipper"),
("venv\\Lib\\site-packages\\scipy", "scipy"),
("venv\\Lib\\site-packages\\imgaug", "imgaug"),
("venv\\Lib\\site-packages\\imageio", "imageio"),
("venv\\Lib\\site-packages\\attrdict", "attrdict")]
params = []
for item in extra_data:
src_path = os.path.join(root_path, item[0])
params.extend(["--add-data", f"{src_path};{item[1]}"])
return params
among imghdr yes Python A file in the directory , Just call it directly in the program code
import imghdr
import shapely
Situation three
error
subprocess Error of . It is also the case that there are multiple exe The problem of
Solution
In this file in the virtual environment \site-packages\paddle\dataset\image.py
if six.PY3:
import subprocess
import sys
import_cv2_proc = subprocess.Popen(
[sys.executable, "-c", "import cv2"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = import_cv2_proc.communicate()
retcode = import_cv2_proc.poll()
if retcode != 0:
cv2 = None
else:
import cv2
else:
try:
import cv2
except ImportError:
cv2 = None
Delete the above code , Change to the following
try:
import cv2
except ImportError:
cv2 = None
边栏推荐
猜你喜欢
随机推荐
Self criticism record of senior senior students
[ctf real question] 2018 WANGDING cup web unfinish
4、 Operation of numerical variables
ESP8266 STA_ UDP_ Client
软件测试面试题之xpath
ESP8266 STA_TCP_Client
十四、sed
VirtualBox VMS extended disk space
Unity screenshot widget
The difference between if and else if
SSH和NFS服务
Basic DOS commands
Shell
Web server (01) -- Introduction to web server
引导过程与服务控制
[untitled]
7、 Loop statement
Mqtt protocol ----- above
1100: finding the number of combinations (function topic)
Li Kou brushes 300 record posts









