![](/img/trans.png)
[英]After using pyinstaller to make my program into an exe, selenium stops working
[英]python script not working after using pyinstaller to make it .exe
path = os.path.realpath(__file__)
try:
shutil.move(path, "C:\\Users\\pc\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup")
except:
pass
try:
if os.path.exists("C:\\Users\\pc\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{}".format(os.path.basename(__file__))):
os.remove(path)
except:
pass
使用pyinstaller之后,我在python中的整個代碼塊不再起作用,因此不會將文件移至目標位置。 請記住,它僅通過運行python腳本即可工作,因此我如何使其適應於使用pyinstaller使其成為.exe文件(有效的文件)
__file__
仍指向腳本名稱,該名稱已解壓縮到一個臨時目錄中。
PyInstaller和Py2exe都將sys.executable覆蓋到應用程序的路徑,例如: C:\\Programs\\myApplication\\app.exe
。
您可能需要瀏覽文檔以獲取詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.