pyinstaller 可执行文件不在 Ubuntu 18.04.1 中运行 [英] pyinstaller executable doesn't run in Ubuntu 18.04.1
问题描述
我浏览了其他帖子,它们似乎没有解决当我尝试执行编译程序时什么都没有发生的特定问题.
I looked through other posts and they didn't seem to address the specific issue where nothing happens when I try to execute a compiled program.
不确定这是 Ubuntu 问题还是 python 问题...不管怎样,我对两者都很陌生,所以我确定对此有一些简单的答案.
Not sure if this is an Ubuntu issue or a python issue... Either way I'm very new to both so I'm sure there's some simple answer to this.
我写了一个简单的程序
print("hello")
input("now")
并使用 pyinstaller 将其编译为单个文件.
and used pyinstaller to compile it into a single file.
pyninstaller --onefile test.py当我尝试通过在 GUI 中双击它来运行该文件时,什么也没有发生 - 没有错误,没有控制台.我检查了属性,它被标记为可执行文件.
pyninstaller --onefile test.py When I try to run the file by double clicking it in the GUInothing at all happens - no error, no console. I checked properties and it is tagged as executable.
当我尝试运行它时,我首先做了一个 ls 以确保我在正确的目录中
I did an ls first to make sure I was in the correct directory when I tried to run it
eric@eric-linux:~/PycharmProjects/helloworld/dist$ ls
mytest test
为了运行它,我输入了
eric@eric-linux:~/PycharmProjects/helloworld/dist$mytest
并得到错误:
Command 'mytest' not found, did you mean:
command 'mtest' from deb parmetis-test
command 'pytest' from deb python-pytest
我还尝试使用 --debug 进行编译,并在运行时再次得到相同的结果.在 Ubuntu 中我需要做一些单独的事情来运行可执行文件吗?
I also tried compiling with --debug and again got the same result when I ran it. Is there something separate I have to do in Ubuntu to run an executable?
推荐答案
尝试像这样运行它:./mytest
如果指定文件的相对路径,Bash 只会查找当前目录.
Bash only looks is the current directory if you specify the relative path to the file.
这篇关于pyinstaller 可执行文件不在 Ubuntu 18.04.1 中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!