python rpy2+pyinstaller_从零开始创建基于python的可执行文件 - Pyinstaller

In the post, I’ll show you how to build a simple interactive app using python and make it executable under all major operating systems.

First, Let’s see what the app can do.https://www.zhihu.com/video/1160081743259512832

From the video, we can see that the app takes in your name and your hobby, and then return your basic description.

Now, let’s build this simple app from scratch.

Step 1 - create a new conda environment

It’s always a good hobby to create a separate environment for your project.

conda create --name app

conda activate app

Step 2 - install required packages

Since this project is very basic, we only need to install Pyinstaller

pip install pyinstaller

Note that For Windows, PyWin32 or the more recent pypiwin32, is a prerequisite. The latter is installed automatically when you install PyInstaller using pip or easy_install. If necessary, follow the pypiwin32 link to install it manually.

Step 3 - write the script

in app.py script

# get the name of the user

print("\n22:First, please tell me your name : ) ")

name = input("Me:My name is:")

# get the hobbies of the user

print("\n22:Oh, I see. And your hobbies are? ")

hobbies = input("Me:My hobbies are:")

# give result

print("\n22:haha, I got you! ")

print("22:your name is ", name, "and your hobbis are", hobbies,"\n")

Step 4 - make the python file executable

in the terminal under the same directory as app.py

pyinstaller --onefile app.py

Step 5 - find the executable file under the dist directory

The pyinstaller will automically create multiple files, just double click the executable app file under dist directory, and then you can play with it and send it to your friends!

Now, you can play with your new app! Isn’t that so simple?

NOTE:

If you use pyinstalled under mac or linux system, then the file can be run in linux system, but not in windows.

If you pyinstalled the script under windows, then it can be run in windows, but not in linux.

请关注我的微信公众号 2加2加2~ 谢谢~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值