gpt4 book ai didi

python-3.x - 属性错误 : Module 'PyQt5' has no attribute '__version__'

转载 作者:行者123 更新时间:2023-12-04 11:26:03 28 4
gpt4 key购买 nike

我试图将 python 文件变形为 .exe 文件。但是有了这两行,我就遇到了这个问题。

import cv2
exit()
Traceback (most recent call last):
File "d:\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "d:\anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "d:\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "d:\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "d:\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 758, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "d:\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 705, in build
exec(code, spec_namespace)
File "D:\solar_cell\main.spec", line 7, in <module>
a = Analysis(['main.py'],
File "d:\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 254, in __init__
self.__postinit__()
File "d:\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 159, in __postinit__
self.assemble()
File "d:\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 433, in assemble
self.graph.process_post_graph_hooks(self)
File "d:\anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 373, in process_post_graph_hooks
module_hook.post_graph(analysis)
File "d:\anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 451, in post_graph
self._load_hook_module()
File "d:\anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 408, in _load_hook_module
self._hook_module = importlib_load_source(
File "d:\anaconda3\lib\site-packages\PyInstaller\compat.py", line 637, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 522, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 1027, in load_module
File "<frozen importlib._bootstrap_external>", line 852, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 702, in _load
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "d:\anaconda3\lib\site-packages\PyInstaller\hooks\hook-PyQt5.py", line 14, in <module>
from PyInstaller.utils.hooks.qt import pyqt5_library_info, get_qt_binaries
File "d:\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 122, in <module>
pyqt5_library_info = Qt5LibraryInfo('PyQt5')
File "d:\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 50, in __init__
if hooks.is_module_satisfies("PyQt5 >= 5.15.4"):
File "d:\anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 533, in is_module_satisfies
version = get_module_attribute(module_name, version_attr)
File "d:\anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 329, in get_module_attribute
raise AttributeError(
AttributeError: Module 'PyQt5' has no attribute '__version__'
如果我只是打印如下内容: print('dsfdsfs') ,那么就可以成功打包成.exe了。
我的环境:
赢10
pyinstaller 5.0.dev0
opencv-python 4.5.2.54
pyqt 5.9.2
我正在使用 anaconda prompt 这样做。

最佳答案

我正在使用 pyinstaller 和 anaconda prompt 并发现了同样的问题,要解决它你必须pip install PyQt5 --user --use-feature=2020-resolver然后再次运行 pyinstaller。

关于python-3.x - 属性错误 : Module 'PyQt5' has no attribute '__version__' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67884654/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com