如何转换python中可执行的python脚本?

时间:2021-09-30 23:53:32

I am trying to convert a python scripts as an executable file for Linux.

我试图将python脚本转换为Linux的可执行文件。

I use freeze.py script to convert a python script into an executable file.

我使用freeze.py脚本将python脚本转换为可执行文件。

I get this output:

我得到这个输出:

~$ python freeze.py carbuddy.py
Traceback (most recent call last):
File "freeze.py", line 100, in <module>
import checkextensions
File "/home/darknight/checkextensions.py", line 6, in <module>
import parsesetup
ImportError: No module named parsesetup  

(Where carbuddy.py is the scripts which I would like to convert into an executable)

(其中carbuddy.py是我想要转换为可执行文件的脚本)

2 个解决方案

#1


1  

I'm aware of freeze.py but I haven't worked with it that much. I've been trying to use it in my system (Ubuntu 12.04 LTS) but I'm getting the same error as you. So, unfortunately, I can't help that much if you really want to use freeze.py.

我知道freeze.py,但我没有那么多。我一直在尝试在我的系统中使用它(Ubuntu 12.04 LTS),但我得到了和你一样的错误。所以,不幸的是,如果你真的想使用freeze.py,我帮不了那么多。

But if you are trying to make executables, why don't you look at Cython? It is not exactly meant for making binary executables out of Python but it is possible. You'd have to invoke GCC (which is longer to type than good ol' freeze) but that's the only downside as far as I can tell. See this SO answer for more details.

但是如果你想制作可执行文件,为什么不看看Cython?它并不完全是用Python制作二进制可执行文件,但它是可能的。你必须调用GCC(它的输入时间比冷冻更好),但就我所知,这是唯一的缺点。有关详细信息,请参阅此SO答案。

#2


0  

Have you considered using other tools, like http://cx-freeze.sourceforge.net/ ?

您是否考虑过使用其他工具,例如http://cx-freeze.sourceforge.net/?

#1


1  

I'm aware of freeze.py but I haven't worked with it that much. I've been trying to use it in my system (Ubuntu 12.04 LTS) but I'm getting the same error as you. So, unfortunately, I can't help that much if you really want to use freeze.py.

我知道freeze.py,但我没有那么多。我一直在尝试在我的系统中使用它(Ubuntu 12.04 LTS),但我得到了和你一样的错误。所以,不幸的是,如果你真的想使用freeze.py,我帮不了那么多。

But if you are trying to make executables, why don't you look at Cython? It is not exactly meant for making binary executables out of Python but it is possible. You'd have to invoke GCC (which is longer to type than good ol' freeze) but that's the only downside as far as I can tell. See this SO answer for more details.

但是如果你想制作可执行文件,为什么不看看Cython?它并不完全是用Python制作二进制可执行文件,但它是可能的。你必须调用GCC(它的输入时间比冷冻更好),但就我所知,这是唯一的缺点。有关详细信息,请参阅此SO答案。

#2


0  

Have you considered using other tools, like http://cx-freeze.sourceforge.net/ ?

您是否考虑过使用其他工具,例如http://cx-freeze.sourceforge.net/?