Embed python interpreter in a python application

2019-03-27 11:42发布

i'm looking for a way to ship the python interpreter with my application (also written in python), so that it doesn't need to have python installed on the machine.

I searched google and found a bunch of results about how to embed the python interpreter in applications written in various languages, but nothing for applications writtent in python itself... I don't need to "hide" my code or make a binary like cx_freeze does, i just don't want my users to have to install python to use my app, that's all.

Thanks.

5条回答
看我几分像从前
2楼-- · 2019-03-27 12:19

For Windows: py2exe

For Linux: Freeze

Full disclosure: I've only read about these, never used them. Perhaps some who has can comment?

查看更多
Explosion°爆炸
3楼-- · 2019-03-27 12:29

You need some sort of executable in order to start Python. May as well be the one your app has been frozen into.

The alternative is to copy the executable, library, and pieces of the stdlib that you need into a private directory and invoke that against your app.

查看更多
放荡不羁爱自由
4楼-- · 2019-03-27 12:30

Have a look at http://www.python-packager.com, it is a free webservice for building redistrutable python binaries based on pyinstaller. I've used it to build apps for Windows and it is very easy to use and also works with GUI apps.

查看更多
Juvenile、少年°
5楼-- · 2019-03-27 12:35

For distribution on Windows machines, look into py2exe

py2exe is a Python Distutils extension which converts Python scripts 
into executable Windows programs, able to run without requiring a 
Python installation

For the MacIntosh, there is py2app (but I'm not familiar with it)

And for both Windows and Linux, there's bbfreeze or also pyinstaller

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-03-27 12:39

Making a frozen binary using a utility like cx_freeze or py2exe is probably the easiest way to do this. That way you only need to distribute the executable. I know that you might prefer not to distribute a binary, but if that is a concern you could always give users the option to download the source and run from an interpreter.

查看更多
登录 后发表回答