【问题标题】:When i try to build an executable file with pyinstaller only a .spec file is created, How do i build an executable with pyinstaller当我尝试使用 pyinstaller 构建可执行文件时,仅创建一个 .spec 文件,如何使用 pyinstaller 构建可执行文件
【发布时间】:2020-04-11 07:41:30
【问题描述】:

我正在使用 Anaconda 提示符,在导航到 python 代码所在的文件夹后,我运行了命令 pyinstaller --onefile 练习9.py 我注意到只创建了一个名为 exercise9.spec 的文件。我没有看到我想在其中找到 .exe 文件的 dist 文件夹,如正在使用的教程所述。

这是我正在尝试执行的python代码

from getpass import getpass
def login():
     username = input("Please enter your username: ")
     password = getpass("Please enter your password: ")
     return [username, password]
try:
    login_details = login()
    if login_details[0] != "admin": 
        raise ValueError()
    elif login_details[1] != "password":
        print("Wrong Password")

    else:
        print("Login successful")
        input("Press enter to exit")
except ValueError:
    print("Wrong User name")

这是exercise9.spec文件的内容

block_cipher = None

 a = Analysis(['exercise9.py'],
         pathex=['C:\\Users\\USER\\Desktop\\schoology\\exer9'],
         binaries=[],
         datas=[],
         hiddenimports=[],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher,
         noarchive=False)
 pyz = PYZ(a.pure, a.zipped_data,
         cipher=block_cipher)
 exe = EXE(pyz,
      a.scripts,
      a.binaries,
      a.zipfiles,
      a.datas,
      [],
      name='exercise9',
      debug=False,
      bootloader_ignore_signals=False,
      strip=False,
      upx=True,
      upx_exclude=[],
      runtime_tmpdir=None,
      console=True )

请帮帮我,我也尝试使用我编写的其他 gui 代码,但只创建了 .spec 文件,我使用的是 Windows 7。

【问题讨论】:

    标签: python pyinstaller


    【解决方案1】:

    我已经能够通过在 anaconda 提示符下导航到脚本目录并输入以下命令来解决该问题:

    python -m PyInstaller --onefile exercise9.py
    

    【讨论】:

      猜你喜欢
      • 2019-01-17
      • 2016-12-13
      • 1970-01-01
      • 2018-12-29
      • 2020-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-23
      相关资源
      最近更新 更多