我正在尝试将python文件转换为exe文件,但无法正常工作

问题描述

我尝试使用java.awt.graphicsenv sun.awt.X11GraphicsEnvironment java.awt.headless true java.awt.printerjob sun.print.PSPrinterJob java.class.path /usr/share/jenkins/jenkins.war java.class.version 52.0 java.endorsed.dirs /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/lib/endorsed java.ext.dirs /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/lib/ext:/usr/java/packages/lib/ext java.home /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre java.io.tmpdir /tmp java.library.path /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib java.runtime.name OpenJDK Runtime Environment java.runtime.version 1.8.0_262-b10 java.specification.name Java Platform API Specification java.specification.vendor Oracle Corporation java.specification.version 1.8 java.vendor Oracle Corporation java.vendor.url http://java.oracle.com/ java.vendor.url.bug http://bugreport.sun.com/bugreport/ java.version 1.8.0_262 java.vm.info mixed mode java.vm.name OpenJDK 64-Bit Server VM java.vm.specification.name Java Virtual Machine Specification java.vm.specification.vendor Oracle Corporation java.vm.specification.version 1.8 java.vm.vendor Oracle Corporation java.vm.version 25.262-b10 将python文件制作为exe文件 。尝试从dist打开exe时出现错误,因此我使用了pyinstaller main.py --onefile --noconsole并说--debug=all

我第一次不确定我到底是怎么做的。

解决方法

要将python文件转换为exe:

  1. 确保已安装pyinstaller并保持最新状态

    pip install pyinstaller

  2. 在PowerShell中键入以下内容:

    pyinstaller --onefile -w 'youfilename.py'

文件名应显示为1.exe 确保位于正确的目录中

如果您有更多疑问,请使用以下链接:https://www.geeksforgeeks.org/convert-python-script-to-exe-file/