Python: Ubuntu14下用PyInstaller打包.py成一个单独的可执行文件_20160701_七侠镇莫尛貝

来源:互联网 发布:时间序列数据回归分析 编辑:程序博客网 时间:2024/06/05 04:49

参考资料:

1.http://pythonhosted.org/PyInstaller/

2.http://www.cnblogs.com/mywolrd/p/4756005.html

3.http://stackoverflow.com/questions/31767469/pyinstaller-path-or-glob-usr-include-python3-4m-pyconfig-h-not-found-or-matc


安装pip: apt install python-pip

安装pyinstaller:pip install pyinstaller

安装libpython2.7-dev:apt install libpython2.7-dev


打包.py文件: pyinstaller -F smsweb.py          (-F参数表示打包成一个单独的可执行文件,不需要其他依赖库)

当前dist目录下的smsweb即是我们要的东西。


  • pyi-archive_viewer : 查看可执行包里面的文件列表。
  • pyi-bindepend : 查看可执行文件依赖的动态库(.so或.dll文件)
使用方法:

nohup ./smsweb 48080 &

(旧的.py文件运行方式:nohup python ./smsweb.py 48080 &)

即smsweb = python smsweb.py,其他相关的启动、停止、列出进程脚本中的smsweb.py要相应地去掉.py。


20170314补充:

如果有多个.py文件希望打成一个exe,则指定多个.py文件完整路径。如:

pyinstaller -F ./smsweb.py ./tool/*.py ./db/db.py

说明:将当前目录的smsweb.py,db目录下的db.py,tool目录下的所有.py文件,都打成一个exe。


exe在ubuntu14.04下测试运行通过。





0 0
原创粉丝点击