Python - pyinstaller - 由 pyinstaller 执行的项目出现错误 执行脚本 pyi_rth_pkges 失败。

问题描述 投票:0回答:1

我试图通过pyinstaller执行项目,但有错误Failed to execute脚本pyi_rth_pkges ,运行程序后。

大家好,这是项目结构。 tree /F app-1.0.1

│   LICENSE
│   main.py      # this module to run GUI build by tkinter
│   MANIFEST.in
│   PKG-INFO
│   README.md
│   setup.cfg
│   setup.py      # this is the module to package all application
│
├───app.egg-info
│       dependency_links.txt
│       entry_points.txt
│       PKG-INFO
│       requires.txt
│       SOURCES.txt
│       top_level.txt
│
├───components
│       frame.py 
│       menu.py
│       vie.py
│       __init__.py
│
├───lib
│       functions.py
│       variable.py
│       __init__.py
│
├───pages
│       winAbout.py
│       win_star.py
│       __init__.py
│
├───data
    │   __init__.py
    │
    └───image
            logo.ico
            home.jpg
            __init__.py

这是setup.py代码。

from setuptools import setup , find_packages

setup(
    name="app",
    version="1.0.1",
    description="A Python package to get Auto reports for any Site.",
    author="john",
    author_email="[email protected]",
    license="MIT",
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
    ],
    packages=find_packages(),
    package_data={
        'data': ['image/*.ico', 'image/*.jpg'],
    },
    install_requires= ['Pillow'],
    entry_points={
        'console_scripts': [
            'napp=main:App'
        ]
    }
)

使用代码后。 pyinstaller --onefile -w setup.py 我在Shell中看到的消息。

1699 INFO: PyInstaller: 3.6
1699 INFO: Python: 3.8.2
1715 INFO: Platform: Windows-10-10.0.18362-SP0
1715 INFO: wrote C:\Users\JOHN\Desktop\app\setup.spec
1730 INFO: UPX is not available.
1768 INFO: Extending PYTHONPATH with paths
['C:\\Users\\JOHN\\Desktop\\app', 'C:\\Users\\JOHN\\Desktop\\app']
1768 INFO: checking Analysis
1768 INFO: Building Analysis because Analysis-00.toc is non existent
1768 INFO: Initializing module dependency graph...
1784 INFO: Caching module graph hooks...
1815 INFO: Analyzing base_library.zip ...
11684 INFO: Processing pre-find module path hook   distutils
11690 INFO: distutils: retargeting to non-venv dir 'c:\\python\\lib'
24084 INFO: Caching module dependency graph...
24348 INFO: running Analysis Analysis-00.toc
24448 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\python.exe
24702 INFO: Analyzing C:\Users\JOHN\Desktop\Amazon\setup.py
25809 INFO: Processing pre-find module path hook   site
25840 INFO: site: retargeting to fake-dir 'c:\\python\\lib\\site-packages\\PyInstaller\\fake-modules'
32617 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
34642 INFO: Processing module hooks...
34642 INFO: Loading module hook "hook-distutils.py"...
34695 INFO: Loading module hook "hook-encodings.py"...
34858 INFO: Loading module hook "hook-lib2to3.py"...
34958 INFO: Loading module hook "hook-pkg_resources.py"...
36349 INFO: Processing pre-safe import module hook   win32com
36581 INFO: Excluding import '__main__'
36581 INFO:   Removing import of __main__ from module pkg_resources
36581 INFO: Loading module hook "hook-pycparser.py"...
36618 INFO: Loading module hook "hook-pydoc.py"...
36618 INFO: Loading module hook "hook-pythoncom.py"...
37182 INFO: Loading module hook "hook-pywintypes.py"...
37745 INFO: Loading module hook "hook-setuptools.py"...
39108 INFO: Loading module hook "hook-sysconfig.py"...
39126 INFO: Loading module hook "hook-win32com.py"...
c:\python\lib\site-packages\win32com\client\makepy.py:369: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if path is not '' and not os.path.exists(path):
40488 INFO: Loading module hook "hook-xml.dom.domreg.py"...
40519 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
40519 INFO: Loading module hook "hook-xml.py"...
40519 INFO: Loading module hook "hook-_tkinter.py"...
41461 INFO: checking Tree
41461 INFO: Building Tree because Tree-00.toc is non existent
41461 INFO: Building Tree Tree-00.toc
41923 INFO: checking Tree
41923 INFO: Building Tree because Tree-01.toc is non existent
41923 INFO: Building Tree Tree-01.toc
42005 INFO: Looking for ctypes DLLs
42121 INFO: Analyzing run-time hooks ...
42121 INFO: Including run-time hook 'pyi_rth__tkinter.py'
42158 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
42205 INFO: Including run-time hook 'pyi_rth_pkgres.py'
42220 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
42289 INFO: Looking for dynamic libraries
44434 INFO: Looking for eggs
44434 INFO: Using Python library c:\python\python38.dll
44434 INFO: Found binding redirects:
[]
44465 INFO: Warnings written to C:\Users\JOHN\Desktop\app\build\setup\warn-setup.txt
44614 INFO: Graph cross-reference written to C:\Users\JOHN\Desktop\app\build\setup\xref-setup.html
44773 INFO: checking PYZ
44773 INFO: Building PYZ because PYZ-00.toc is non existent
44773 INFO: Building PYZ (ZlibArchive) C:\Users\JOHN\Desktop\app\build\setup\PYZ-00.pyz
46679 INFO: Building PYZ (ZlibArchive) C:\Users\JOHN\Desktop\app\build\setup\PYZ-00.pyz completed successfully.
46759 INFO: checking PKG
46759 INFO: Building PKG because PKG-00.toc is non existent
46759 INFO: Building PKG (CArchive) PKG-00.pkg
66169 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
66215 INFO: Bootloader c:\python\lib\site-packages\PyInstaller\bootloader\Windows-32bit\runw.exe
66215 INFO: checking EXE
66215 INFO: Building EXE because EXE-00.toc is non existent
66231 INFO: Building EXE from EXE-00.toc
66247 INFO: Appending archive to EXE C:\Users\JOHN\Desktop\app\dist\setup.exe
66331 INFO: Building EXE from EXE-00.toc completed successfully.

我得到'dist'文件夹中有Setup.exe,但从sheel运行后,我看到这个错误。

PS C:\Users\JOHN\Desktop\app\dist> Setup.exe
Setup.exe : The term 'Setup.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Setup.exe
+ ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Setup.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Suggestion [3,General]: The command Setup.exe was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\Setup.exe". See "get-help about_Command_Precedence" for more details.

从文件夹中运行Setup.exe后,我看到这个错误信息。

enter image description here

python python-3.x selenium pyinstaller
1个回答
-1
投票

你应该在你的主文件中加入以下导入代码

import pkg_resources.py2_warn

你也可以输入这个来尝试解决问题

pip uninstall pyinstaller

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

© www.soinside.com 2019 - 2024. All rights reserved.