简体   繁体   English

当我尝试使用 pyinstaller 构建可执行文件时,只创建了 a.spec 文件,如何使用 pyinstaller 构建可执行文件

[英]When i try to build an executable file with pyinstaller only a .spec file is created, How do i build an executable with pyinstaller

Am using Anaconda prompt, after navigating to the folder where the python code is, i ran the command pyinstaller --onefile exercise9.py I noticed that only a file called exercise9.spec was created.我正在使用 Anaconda 提示符,在导航到 python 代码所在的文件夹后,我运行了命令 pyinstaller --onefile exercise9.py 我注意到只创建了一个名为 exercise9.spec 的文件。 i did not see the dist folder where am suppose to find the.exe file as stated by the tutorials am using.我没有看到我想在其中找到.exe 文件的 dist 文件夹,如正在使用的教程中所述。

Here is the python code am trying to execute这是我试图执行的 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")

Here is the content of the exercise9.spec file这是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 )

help me out please i tried with other gui codes i wrote too, but only.spec file is created, am using windows 7.请帮帮我,我也尝试使用我编写的其他 gui 代码,但只创建了.spec 文件,我使用的是 windows 7。

I have been able to solve the issue by navigating to the scripts directory in anaconda prompt and entering this command:我已经能够通过导航到 anaconda 提示符中的脚本目录并输入以下命令来解决该问题:

python -m PyInstaller --onefile exercise9.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pyInstaller 仅构建可执行文件 - pyInstaller build executable only 如何使用 pyinstaller 在可执行文件中包含 .dll 文件? - How do I include .dll file in executable using pyinstaller? 如何使用 pyinstaller 将多个 .py 文件构建为单个可执行文件? - How to build multiple .py files into a single executable file using pyinstaller? pyinstaller:当我用pyinstaller制作.exe文件时,在python中使用内置函数打开的可执行文件关闭1秒 - Pyinstaller: Executable file opened with built in function in python closes after 1 sec when i make .exe file with pyinstaller pyinstaller build生成可执行文件后添加文件的位置 - Location of the added files after the executable file is generated by pyinstaller build Pyinstaller 可执行文件未运行 - Pyinstaller Executable File Not Running 如何使用PyInstaller从PyCharm项目中创建可执行文件? - How do I create an executable file out of a PyCharm project using PyInstaller? 如何在 PyInstaller 中指定 .spec 文件 - How can I specifiy the .spec file in PyInstaller 如何允许 python 脚本复制使用 pyinstaller 创建的可执行文件? - How to allow python script to replicate the executable file created with pyinstaller? Pyinstaller 独立可执行文件找不到规范文件中定义的 ui 文件 - Pyinstaller standalone executable cannot find ui file defined in spec file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM