Distributing python application tutorials

安稳与你 提交于 2020-03-05 14:14:38

问题


Hi as a python newbie I have written a small python application that can convert an excel worksheet into a sqlite database table. Its not a terribly complex application but it does make use of external modules/package like xlrd (http://pypi.python.org/pypi/xlrd) which I had to download and install when writing my app. Now that is all done I would like to distribute it amongst my friends, all windows users, while they have python on their machines, they may or may not have the xlrd modules.

I would like to package my app, make sure it includes everything that it needs to run, and share the final .zip file with my friends so they can use the application. Is there a good tutorial that covers how to package a python application, with all the necessary external modules/packages, so that another windows user, can easily run my application.

I keep hearing about disutils, can anyone point me to some good tutorials, or any other python packaging tutorials that show how to get everything into a simple easy to distribute file. Many thanks

Note: I also want to include the sqlite database file with my application, so the end user doesn't have to worry about anything


回答1:


First download Pyinstaller and save it somewhere. Then, if you're running Python 2.6 or 2.7 go and install pywin32.

Go create a directory for your output file.

Open Command prompt and enter the fallowing:

python path/to/pyinstaller/pyinstall.py file/to/be/converted.py --onefile 

If you want to add an icon, add the --icon argument.

If you want it to hide the CMD window add the --windowed argument.

So if you wanted it to use an icon and hide the CMD window it would look like this:

python path/to/pyinstaller/pyinstall.py file/to/be/converted.py --onefile --icon="path/to/icon.ico" --windowed

The --onefile argument makes the saves everything into one file, without it, the output would be would be a lot of files.

The output is saved in the "dist" folder in the directory it was using.

After you convert the python script in to an .exe, put it in a .zip file along with any other files you need (in your case the squite database file) and you can give it to anyone without them needing to have Python at all.

If you want a program to do this all for you, you can download a program called PTEC.



来源:https://stackoverflow.com/questions/12776380/distributing-python-application-tutorials

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!