鱼C论坛

 找回密码
 立即注册
查看: 3706|回复: 5

pyinstaller 有的py代码可以发布,有的py代码不能呢?

[复制链接]
发表于 2021-7-15 23:36:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
请指点一下pyinstaller 使用中的问题。

  我编写了代码 GraySunlight.py
ANACONDA运行没有问题,但我想用pyinstaller发布时,出错了。build目录里只有两个文件如下图;dist目录里是空的,没有生成exe文件。
使用时我是从DOS进入PY文件所在的目录下,然后运行命令 pyinstaller -F GraySunlight.py


屏幕显示如下:我的GraySunlight.py代码在附件中

C:\Pythontry>pyinstaller GraySunlight.py
1479 INFO: PyInstaller: 4.4
1479 INFO: Python: 3.7.0 (conda)
1480 INFO: Platform: Windows-10-10.0.17134-SP0
1481 INFO: wrote C:\Pythontry\GraySunlight.spec
1551 INFO: UPX is available.
1556 INFO: Extending PYTHONPATH with paths
['C:\\Pythontry', 'C:\\Pythontry']
1620 INFO: checking Analysis
1621 INFO: Building Analysis because Analysis-00.toc is non existent
1621 INFO: Initializing module dependency graph...
1629 INFO: Caching module graph hooks...
1656 INFO: Analyzing base_library.zip ...
7339 INFO: Caching module dependency graph...
7575 INFO: running Analysis Analysis-00.toc
7594 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\dawson\anaconda3\python.exe
7894 INFO: Analyzing C:\Pythontry\GraySunlight.py
11058 INFO: Processing pre-find module path hook distutils from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
11060 INFO: distutils: retargeting to non-venv dir 'c:\\users\\dawson\\anaconda3\\lib'
11531 INFO: Processing pre-find module path hook site from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
11532 INFO: site: retargeting to fake-dir 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\fake-modules'
15467 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-setuptools.extern.six.moves.py'.
27569 INFO: Processing pre-safe import module hook six.moves from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
34183 INFO: Processing module hooks...
34184 INFO: Loading module hook 'hook-pycparser.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
34432 INFO: Loading module hook 'hook-pytest.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
36083 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36087 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36089 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36093 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36228 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36232 INFO: Loading module hook 'hook-importlib_metadata.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36236 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36353 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36356 INFO: Import to be excluded not found: 'test'
36356 INFO: Loading module hook 'hook-numpy.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36491 WARNING: Hidden import "numpy.core._dtype_ctypes" not found!
36502 INFO: Import to be excluded not found: 'f2py'
36525 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
36529 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
37474 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
37479 INFO: Loading module hook 'hook-PIL.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
37483 INFO: Import to be excluded not found: 'PySide2'
37483 INFO: Import to be excluded not found: 'PyQt6'
37484 INFO: Import to be excluded not found: 'PySide6'
37487 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
37493 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
39080 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
39943 WARNING: Hidden import "pkg_resources.py2_warn" not found!
40312 WARNING: Hidden import "pkg_resources.markers" not found!
40316 INFO: Loading module hook 'hook-PyQt5.py' from 'c:\\users\\dawson\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
Traceback (most recent call last):
  File "c:\users\dawson\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\dawson\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Dawson\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 126, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\dawson\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 "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 705, in build
    exec(code, spec_namespace)
  File "C:\Pythontry\GraySunlight.spec", line 19, in <module>
    noarchive=False)
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 254, in __init__
    self.__postinit__()
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 159, in __postinit__
    self.assemble()
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 433, in assemble
    self.graph.process_post_graph_hooks(self)
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 373, in process_post_graph_hooks
    module_hook.post_graph(analysis)
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 451, in post_graph
    self._load_hook_module()
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 409, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\compat.py", line 632, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\hooks\hook-PyQt5.py", line 11, in <module>
    from PyInstaller.utils.hooks.qt import pyqt5_library_info, \
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 162, in <module>
    pyqt5_library_info = QtLibraryInfo('PyQt5')
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 54, in __init__
    if hooks.is_module_satisfies("PyQt5 >= 5.15.4"):
  File "c:\users\dawson\anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 502, in is_module_satisfies
    version = get_module_attribute(module_name, version_attr)
  File "c:\users\dawson\anaconda3\lib\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__'
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-7-16 07:36:18 | 显示全部楼层
-w是GUI。-f是没有界面的。
是不是搞错了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-7-16 12:20:28 | 显示全部楼层
青出于蓝 发表于 2021-7-16 07:36
-w是GUI。-f是没有界面的。
是不是搞错了

你是说 命令 pyinstaller -F GraySunlight.py 么?
问题不是这里吧,我用 打印“HELLO”的PY代码测试过,用pyinstaller -F 没问题
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-7-16 22:54:11 | 显示全部楼层
你把命令改成pyinstaller -F GraySunlight.py改w试一下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-7-18 16:56:58 | 显示全部楼层
本帖最后由 daweiba 于 2021-7-18 21:55 编辑
聂嘉辉 发表于 2021-7-16 22:54
你把命令改成pyinstaller -F GraySunlight.py改w试一下


是说把命令行改成 pyinstaller -w GraySunlight.py 么?

试了 pyinstaller -w GraySunlight.py 和 pyinstaller -F GraySunlight.py -w ,两个都不行
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-8-31 13:24:38 | 显示全部楼层
daweiba 发表于 2021-7-18 16:56
是说把命令行改成 pyinstaller -w GraySunlight.py 么?

试了 pyinstaller -w GraySunlight.py 和 p ...

pip install PyQt5 --user --use-feature=2020-resolver
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-4 17:40

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表