簡體   English   中英

使用 py-to-exe 的黑色控制台

[英]black console using py-to-exe

我嘗試使用 pyinstaller 從我的 main_app.py 制作一個可執行文件。 一切正常,但當我雙擊 .exe 文件時,它只彈出一個黑色控制台,而不是應用程序。

這是我使用的命令:

pyinstaller --onefile -w main_app.py

我還使用並自動執行所有變體,我有同樣的問題,雙擊后 .exe 上沒有顯示任何內容,只有黑色控制台

這是我的項目的樣子: 目錄文件

我有 main_app.py 文件,它從不同的子目錄調用其他腳本:

from gitscripts.main_git import gitmainfunction
from svnscripts.main import svnmainfunction
from jirascripts.jira_main import jiramainfunction
from confluencescripts.confluence_main import confluencemainfunction
print("\nWelcome to `Easy Datas`!\n")
print("Before trying to use the app be sure that you are connected to URA and ADN 2.0 !!\n")
print("Below are the current type of datas that can be processed: ")
print(" SVN (s)\n GIT (g)\n BUGZILLA (b) \n JIRA (j) \n Confluence(c)")


def main_app():
    subject = input("\nChoose for what datas do you want to make the final raport (s/g/b/j/c):")
    match subject:
        case "s":
            svnmainfunction()
        case "g":
            gitmainfunction()
        case "b":
            bugzillamainfunction()
        case "j":
            jiramainfunction()

        case "c":
            confluencemainfunction()
if __name__ == '__main__':
    main_app()```

這是使用 IDE 編譯器 vs.exe 文件的程序的外觀: 在此處輸入圖像描述

他應該顯示左下角的內容,但不是。 在 main_app.py 中,我只是調用了那些子目錄中的所有函數/腳本。 如果有人可以幫我解決這個問題,或者如果您知道其他方法可以將 main_app.py 轉換為 .exe

泰!

您可以為此使用 auto-py-to-exe,鍵入auto-py-to-exe而不是pyinstaller --onefile -w main_app.py因為這並不總是有效。

您必須在構建過程中包含外部腳本,因為帶有腳本的子目錄不會自動對您的*.exe可用。

請參考文檔: https://pyinstaller.org/en/stable/spec-files.html#adding-files-to-the-bundle

這在這篇文章中也有詳細說明(只是一個例子,還有很多): Pyinstaller not pick up Tree or Data files

看起來@ezpie 的回答表明問題出在您這邊。 我建議重新安裝 pyinstaller。 首先卸載pyinstaller: pip uninstall pyinstaller 接下來分別使用以下命令來確保您的 pip 已完全更新:

python -m pip install --upgrade pip
pip install --no-use-wheel --upgrade distribute
pip install --upgrade setuptools

如果--no-use-wheel不起作用使用--no-binary:all:

在此之后重新安裝 pyinstaller pip install pyinstaller

現在確保您在 dist 文件夾而不是 build 文件夾中運行 exe。 最后,如果這很困難,請重新安裝 auto-py-to-exe,然后使用它。 如果問題仍然存在,那么我無法進一步幫助您,因為這聽起來可能是您系統的問題。 希望這可以幫助:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM