cqwcns 发表于 2020-11-25 10:58

python打包为exe失败

python打包为exe失败,麻烦各位大佬帮忙看看什么原因?如何解决?谢谢。

(venv) C:\Users\草青味虫鸟声\PycharmProjects\jianzhi>pyinstaller --console --onefile main.py
343 INFO: PyInstaller: 4.1
344 INFO: Python: 3.9.0
346 INFO: Platform: Windows-10-10.0.19041-SP0
349 INFO: wrote C:\Users\草青味虫鸟声\PycharmProjects\jianzhi\main.spec
359 INFO: UPX is not available.
378 INFO: Extending PYTHONPATH with paths
['C:\\Users\\草青味虫鸟声\\PycharmProjects\\jianzhi',
'C:\\Users\\草青味虫鸟声\\PycharmProjects\\jianzhi']
413 INFO: checking Analysis
414 INFO: Building Analysis because Analysis-00.toc is non existent
415 INFO: Initializing module dependency graph...
430 INFO: Caching module graph hooks...
489 INFO: Analyzing base_library.zip ...
7837 INFO: Processing pre-find module path hook distutils from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
7839 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\\lib'
11963 INFO: Caching module dependency graph...
12413 INFO: running Analysis Analysis-00.toc
12424 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\scripts\python.exe
12478 INFO: Analyzing C:\Users\草青味虫鸟声\PycharmProjects\jianzhi\main.py
16053 INFO: Processing module hooks...
16054 INFO: Loading module hook 'hook-openpyxl.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
17053 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17057 INFO: Excluding import of doctest from module difflib
17058 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17065 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17878 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17882 INFO: Excluding import of doctest from module heapq
17883 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17886 INFO: Excluding import of test from module multiprocessing.util
17887 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17891 INFO: Excluding import of argparse from module pickle
17892 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17899 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
17901 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
18513 INFO: Looking for ctypes DLLs
18518 INFO: Analyzing run-time hooks ...
18525 INFO: Including run-time hook 'c:\\users\\草青味虫鸟声\\pycharmprojects\\jianzhi\\venv\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
18544 INFO: Looking for dynamic libraries
18594 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_multiprocessing.pyd
18639 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\unicodedata.pyd
18676 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\select.pyd
18745 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_socket.pyd
18819 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_decimal.pyd
18892 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_overlapped.pyd
18992 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_ssl.pyd
19060 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_queue.pyd
19171 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\pyexpat.pyd
19231 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_asyncio.pyd
19318 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_hashlib.pyd
19409 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_lzma.pyd
19509 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_bz2.pyd
19618 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_ctypes.pyd
19750 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\DLLs\_elementtree.pyd
20250 INFO: Looking for eggs
20250 INFO: Python library not in binary dependencies. Doing additional searching...
20253 WARNING: Can not get binary dependencies for file: C:\Users\草青味虫鸟声\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
20254 WARNING:   Reason: 'The file is empty'
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
File "C:\Users\草青味虫鸟声\PycharmProjects\jianzhi\venv\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build
    exec(code, spec_namespace)
File "C:\Users\草青味虫鸟声\PycharmProjects\jianzhi\main.spec", line 6, in <module>
    a = Analysis(['main.py'],
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
    self.__postinit__()
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
    self.assemble()
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\building\build_main.py", line 475, in assemble
    self._check_python_library(self.binaries)
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\building\build_main.py", line 564, in _check_python_library
    python_lib = bindepend.get_python_library_path()
File "c:\users\草青味虫鸟声\pycharmprojects\jianzhi\venv\lib\site-packages\PyInstaller\depend\bindepend.py", line 945, in get_python_library_path
    raise IOError(msg)
OSError: Python library not found: libpython3.9.dll, libpython3.9m.dll, libpython39.dll, python39.dll, libpython39m.dll
    This would mean your Python installation doesn't come with proper library files.
    This usually happens by missing development package, or unsuitable build parameters of Python installation.

    * On Debian/Ubuntu, you would need to install Python development packages
      * apt-get install python3-dev
      * apt-get install python-dev
    * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

zxy5821 发表于 2020-11-25 11:10

OSError: Python library not found: libpython3.9.dll, libpython3.9m.dll, libpython39.dll, python39.dll, libpython39m.dll 这一行拿去search一下 应该就能解决了

千城忆梦 发表于 2020-11-25 11:12

依赖的库没找到

辉夜年华 发表于 2020-11-25 11:18

你得把依赖库一起打包了,还有环境

水木杉 发表于 2020-11-25 11:20

python打包建议新开一个虚拟环境把需要的库和pyinstaller重新装上

guowq 发表于 2020-11-25 11:24

本帖最后由 guowq 于 2020-11-25 11:27 编辑

把依赖库一起打包 推荐用anaconda 能省好多事 ps我也是小白

Feng_Harry 发表于 2020-11-25 11:46

包不全,需要弄个新的虚拟环境我一般用的annoconda新建的

woshicp 发表于 2020-11-25 12:18

pip安装依赖到它扫描库的路径
页: [1]
查看完整版本: python打包为exe失败