在 Ubuntu 上,使用 Pyinstaller 创建的可执行文件无法运行 [英] On Ubuntu an executable created with Pyinstaller doesn't run

查看:68
本文介绍了在 Ubuntu 上,使用 Pyinstaller 创建的可执行文件无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 ubuntu 16.04.我正在尝试使用 pyinstaller 使用 pyinstaller --onefile fez.py 从我的 python 脚本 (fez.py) 制作可执行文件.

I am on ubuntu 16.04. I am trying to make an executable from my python script (fez.py) using pyinstaller using pyinstaller --onefile fez.py.

可执行文件的构建没有任何错误.我得到两个文件夹 dist 并使用 dist 中的 .exe 文件构建.我也得到了 fez.spec 文件.但是当我尝试运行可执行文件时,似乎什么也没发生.

The executable gets built without any error. I get the two folders dist and build with the .exe file in dist. I get the fez.spec file too. But when I try to run the executable nothing seems to happen.

我的问题是:

pyinstaller 进程是否存在问题以创建未显示为错误的可执行文件,或者我的 ubuntu 是否存在无法运行可执行文件的问题?运行我的可执行文件的原因是什么?

Is there a problem with the pyinstaller process to create the executable that doesn't get displayed as an error OR is there a problem with my ubuntu that it can't run the executable? Whichever is the reason how to run my executable?

注意:我非常了解 pyinstaller 是特定于操作系统的事实,即对于在 ubuntu 上运行的可执行文件,它应该在 ubuntu 本身上准备好,这正是我所做的.我在 ubuntu 上使用了 pyinstaller 命令.这也排除了我应该安装 wine 或其他类似东西的事实,因为在 ubuntu 上执行 windows 可执行文件需要 wine.(带有 .exe 扩展名的文件)我正在使用 pyinstaller 制作的可执行文件ubuntu 专门为 ubuntu 构建可执行文件.(在属性中,它们显示 application\x-executable)

NB: I am well versed with the fact that pyinstaller is OS specific i.e. for an executable to work on ubuntu it should be prepared on ubuntu itself and that is exactly what I have done. I have used the pyinstaller command on ubuntu. This also rules out the fact that I should install wine or something else of that sort as wine is required to execute windows executables on ubuntu. (Files with .exe extension) The executable I am making using pyinstaller on ubuntu specifically builds executables for ubuntu. (In properties they show application\x-executable)

要运行可执行文件,我必须首先更改权限以允许为可执行文件.然后我不得不从终端运行.但是没有办法双击运行它.

To run the executable I had to first change the permission to allow as executable. Then I had to run from the terminal. But is there no way to run it using double clicks.

推荐答案

要从终端执行 fez 可执行文件,请转到包含该可执行文件的文件夹(即:/home/user/dist 文件夹)并在终端中运行以下命令(这里的可执行文件称为 fez 是可执行文件的名称):

To execute the fez executable from terminal, go to the folder containing the executable (i.e: /home/user/dist folder) and run the below command in terminal (here the executable is called fez is the name of the executable):

~/dist$ ./fez

执行命令后,如果您的脚本有任何打印语句,那么这些语句将显示在终端中.即使您的可执行文件或脚本有任何错误,它们也会显示在终端中.

After executing the command if your script has any print statements then the statements are displayed in the terminal. Even if you executable or script has any errors, they are displayed in terminal.

这篇关于在 Ubuntu 上,使用 Pyinstaller 创建的可执行文件无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆