pyinstaller ModuleNotFoundError: No module named 'paddle'

19k Views Asked by At

I am using pyinstaller to create exe file on windows. I have created anaconda based virtual environment "py38" where I have installed all the packages. I am trying to convert a tkinter file namely "gui.py".When I run using normal

python gui.py

command , it works completely fine. But with pyinstaller it doens't seem to find the module "paddle" that I have installed using following two commands.

python -m pip download paddlepaddle==2.1.2 -f https://www.paddlepaddle.org.cn/whl/windows/mkl/noavx/stable.html --no-index --no-deps
python -m pip install [name].whl

I have been using python 3.8. I have used almost all possible solutions that I can get online about fixing this issue.

The commands I have tried so for to get it fixed

pyinstaller --paths 'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages' --onefile --clean gui.py
pyinstaller --paths 'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages' --onedir gui.py
pyinstaller --hidden-import 'paddle' --onefile --clean gui.py
pyinstaller --hidden-import 'paddlepaddle' --onefile --clean gui.py
pyinstaller --hidden-import 'paddlepaddle' --onedir --clean gui.py

When I use --onedir, the generated exe file also closes down immediately after start. The full log is given below, when I run the pyinstaller with "--paths" specified

>pyinstaller --paths 'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages' --onefile --clean gui.py
586 INFO: PyInstaller: 4.5.1
587 INFO: Python: 3.8.11 (conda)
605 INFO: Platform: Windows-10-10.0.19041-SP0
610 INFO: wrote C:\Users\user\Downloads\recognizer\gui.spec
614 INFO: UPX is not available.
615 INFO: Removing temporary files and cleaning cache in C:\Users\user\AppData\Local\pyinstaller
631 INFO: Extending PYTHONPATH with paths
['C:\\Users\\user\\Downloads\\recognizer',
 "C:\\Users\\user\\Downloads\\recognizer\\'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages'",
 'C:\\Users\\user\\Downloads\\recognizer']
1560 INFO: checking Analysis
1561 INFO: Building Analysis because Analysis-00.toc is non existent
1561 INFO: Initializing module dependency graph...
1569 INFO: Caching module graph hooks...
1620 INFO: Analyzing base_library.zip ...
8791 INFO: Processing pre-find module path hook distutils from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
8794 INFO: distutils: retargeting to non-venv dir 'c:\\users\\user\\anaconda3\\envs\\py38\\lib'
16752 INFO: Caching module dependency graph...
17497 INFO: running Analysis Analysis-00.toc
17507 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\user\anaconda3\envs\py38\python.exe
18231 INFO: Analyzing C:\Users\user\Downloads\recognizer\gui.py
22037 INFO: Processing pre-find module path hook site from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
22042 INFO: site: retargeting to fake-dir 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\fake-modules'
33819 INFO: Processing module hooks...
33822 INFO: Loading module hook 'hook-cv2.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
33832 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
33837 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
33839 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
33845 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34078 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34089 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34191 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34196 INFO: Loading module hook 'hook-numpy.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34318 WARNING: Conda distribution 'numpy', dependency of 'numpy', was not found. If you installed this distribution with pip then you may ignore this warning.
34432 INFO: Import to be excluded not found: 'f2py'
34508 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34514 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34519 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35422 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35428 INFO: Loading module hook 'hook-PIL.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35464 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35470 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
37159 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
37315 WARNING: Hidden import "pkg_resources.py2_warn" not found!
37317 WARNING: Hidden import "pkg_resources.markers" not found!
37322 INFO: Loading module hook 'hook-PyQt5.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
37926 WARNING: Hidden import "sip" not found!
37931 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
38168 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
38743 INFO: Loading module hook 'hook-scipy.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
38756 INFO: Loading module hook 'hook-setuptools.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
40669 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
40673 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41174 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41177 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41179 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41180 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41557 INFO: checking Tree
41557 INFO: Building Tree because Tree-00.toc is non existent
41561 INFO: Building Tree Tree-00.toc
41752 INFO: checking Tree
41756 INFO: Building Tree because Tree-01.toc is non existent
41757 INFO: Building Tree Tree-01.toc
42025 INFO: checking Tree
42030 INFO: Building Tree because Tree-02.toc is non existent
42031 INFO: Building Tree Tree-02.toc
42048 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
42153 INFO: Looking for ctypes DLLs
42340 INFO: Analyzing run-time hooks ...
42354 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
42366 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
42374 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
42379 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
42417 INFO: Looking for dynamic libraries
43704 INFO: Looking for eggs
43706 INFO: Using Python library c:\users\user\anaconda3\envs\py38\python38.dll
43708 INFO: Found binding redirects:
[]
43723 INFO: Warnings written to C:\Users\user\Downloads\recognizer\build\gui\warn-gui.txt
44000 INFO: Graph cross-reference written to C:\Users\user\Downloads\recognizer\build\gui\xref-gui.html
44146 INFO: checking PYZ
44149 INFO: Building PYZ because PYZ-00.toc is non existent
44150 INFO: Building PYZ (ZlibArchive) C:\Users\user\Downloads\recognizer\build\gui\PYZ-00.pyz
46686 INFO: Building PYZ (ZlibArchive) C:\Users\user\Downloads\recognizer\build\gui\PYZ-00.pyz completed successfully.
46773 INFO: checking PKG
46775 INFO: Building PKG because PKG-00.toc is non existent
46777 INFO: Building PKG (CArchive) PKG-00.pkg
92228 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
92319 INFO: Bootloader c:\users\user\anaconda3\envs\py38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
92321 INFO: checking EXE
92321 INFO: Building EXE because EXE-00.toc is non existent
92322 INFO: Building EXE from EXE-00.toc
92326 INFO: Copying icons from ['c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
92461 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
92461 INFO: Writing RT_ICON 1 resource with 3752 bytes
92462 INFO: Writing RT_ICON 2 resource with 2216 bytes
92462 INFO: Writing RT_ICON 3 resource with 1384 bytes
92462 INFO: Writing RT_ICON 4 resource with 37019 bytes
92462 INFO: Writing RT_ICON 5 resource with 9640 bytes
92462 INFO: Writing RT_ICON 6 resource with 4264 bytes
92462 INFO: Writing RT_ICON 7 resource with 1128 bytes
92510 INFO: Updating manifest in C:\Users\user\Downloads\recognizer\build\gui\run.exe.s5i_qt6_
92651 INFO: Updating resource type 24 name 1 language 0
92656 INFO: Appending archive to EXE C:\Users\user\Downloads\recognizer\dist\gui.exe
139969 INFO: Building EXE from EXE-00.toc completed successfully.

(py38) C:\Users\user\Downloads\recognizer>

The error I am shown on exe window is following: enter image description here

I have also created totally new conda environment twice with all the packages reinstalled, even that didn't solve the problem.

if anyone can help me out, that will be very much appreciated

2

There are 2 best solutions below

1
On

If other libraries work well and the problem is only with paddleOCR, try:

pip install paddlepaddle paddleocr
0
On

I was facing the same error. Good Steps can be as follows

  1. pip install paddleocr --upgrade
  2. pip install paddlepaddle

Reference: https://github.com/PaddlePaddle/PaddleOCR/issues/1265#issuecomment-748429488

This solved my issue. Thanks!