Pyinstaller: AttributeError: Module 'PyQt5' has no attribute '__version__'

Hi all,
I’m trying compiling my python code with command:
pyinstaller -F code.py

but error

AttributeError: Module 'PyQt5' has no attribute '__version__'
appears
can someone help me?

Could you paste the full traceback?

same question as above, but here is my full traceback. Also, note, running on raspberry pi :

pyinstaller qt_template.py
122 INFO: PyInstaller: 4.5.1
122 INFO: Python: 3.7.3
124 INFO: Platform: Linux-5.4.72-v7l±armv7l-with-debian-10.6
129 INFO: wrote /home/pi/PycharmProjects/Mastering-GUI-Programming-with-Python/Chapter04/New/qt_template.spec
137 INFO: UPX is not available.
141 INFO: Extending PYTHONPATH with paths
[’/home/pi/PycharmProjects/Mastering-GUI-Programming-with-Python/Chapter04/New’,
‘/home/pi/PycharmProjects/Mastering-GUI-Programming-with-Python/Chapter04/New’]
950 INFO: checking Analysis
951 INFO: Building Analysis because Analysis-00.toc is non existent
951 INFO: Initializing module dependency graph…
956 INFO: Caching module graph hooks…
982 INFO: Analyzing base_library.zip …
11271 INFO: Caching module dependency graph…
11786 INFO: running Analysis Analysis-00.toc
11924 INFO: Analyzing /home/pi/PycharmProjects/Mastering-GUI-Programming-with-Python/Chapter04/New/qt_template.py
12093 INFO: Processing module hooks…
12095 INFO: Loading module hook ‘hook-PyQt5.QtWidgets.py’ from ‘/home/pi/.local/lib/python3.7/site-packages/PyInstaller/hooks’…
Traceback (most recent call last):
File “/home/pi/.local/bin/pyinstaller”, line 10, in
sys.exit(run())
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/main.py”, line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/main.py”, line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py”, line 815, in main
build(specfile, kw.get(‘distpath’), kw.get(‘workpath’), kw.get(‘clean_build’))
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py”, line 762, in build
exec(code, spec_namespace)
File “/home/pi/PycharmProjects/Mastering-GUI-Programming-with-Python/Chapter04/New/qt_template.spec”, line 19, in
noarchive=False)
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py”, line 294, in init
self.postinit()
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/building/datastruct.py”, line 159, in postinit
self.assemble()
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/building/build_main.py”, line 473, in assemble
self.graph.process_post_graph_hooks(self)
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/depend/analysis.py”, line 373, in process_post_graph_hooks
module_hook.post_graph(analysis)
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/depend/imphook.py”, line 451, in post_graph
self._load_hook_module()
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/depend/imphook.py”, line 409, in _load_hook_module
self.hook_module_name, self.hook_filename)
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/compat.py”, line 632, in importlib_load_source
return mod_loader.load_module()
File “”, line 407, in _check_name_wrapper
File “”, line 907, in load_module
File “”, line 732, in load_module
File “”, line 265, in _load_module_shim
File “”, line 696, in _load
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/hooks/hook-PyQt5.QtWidgets.py”, line 11, in
from PyInstaller.utils.hooks.qt import add_qt5_dependencies
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/utils/hooks/qt.py”, line 162, in
pyqt5_library_info = QtLibraryInfo(‘PyQt5’)
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/utils/hooks/qt.py”, line 54, in init
if hooks.is_module_satisfies(“PyQt5 >= 5.15.4”):
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/utils/hooks/init.py”, line 502, in is_module_satisfies
version = get_module_attribute(module_name, version_attr)
File “/home/pi/.local/lib/python3.7/site-packages/PyInstaller/utils/hooks/init.py”, line 353, in get_module_attribute
‘Module %r has no attribute %r’ % (module_name, attr_name))
AttributeError: Module ‘PyQt5’ has no attribute ‘version

yes is the same log for me