Is it possible to convert my .py script to a .app that works through a text box or something?
Thanks
Try py2app.
py2app is a Python setuptools command which will allow you to make
standalone application bundles and plugins from Python scripts. py2app
is similar in purpose and design to py2exe for Windows.
Because this is a vague question, I will provide a general answer.
You need to decide on a GUI framework. There are a number of them to choose from.
PyQt4
http://qt.nokia.com/products/
http://www.riverbankcomputing.co.uk/software/pyqt/download
PySide (LGPL version of PyQt4) - http://www.pyside.org/
GTK - http://www.pygtk.org/
wxPython - http://www.wxpython.org/
TkInter
http://wiki.python.org/moin/TkInter
You could even write a web interface that communicates with your python script via RPC or an HTTP rest interface. Take your pick!
My vote is on PySide/PyQt. Its very flexible and easy to use.
At that point you would then use something like py2app to package up the entire environment into a standalone .app that can be distributed.
You can also use the cross-platform pyinstaller, which is more modern and I've had a good experience with.
sudo pip install pyinstaller
pyinstaller myprogram.py --windowed
There's a lot more configuration if you want to go cross platform, but this may get you started:
http://pythonhosted.org/PyInstaller/#building-mac-os-x-app-bundles
This creates the distrutable. From there I use things like Inno Setup on windows or app2dmg for mac.
Related
Right now, I have a python script that when run, opens up a python window using a package "kivy", while processing data using many other packages. Is there a way for me to combine all of these into a .dmg file that when run, installs all the necessary packages and launches the python application as a .app file?
Know there's a lot of factors and this is really specific, but any help would be appreciated :D
You can use py2app to do this.
My recommendation would be to use py2app - https://py2app.readthedocs.io/en/latest/
Here's some installation instructions.
And here's a small tutorial because why reinvent the wheel - they explain it well, it's a really simple process.
I'm trying to build an application written in python, which can run on Windows without the need to install python or associated libraries(standalone), and I want to do that on my mac. I tried Pyinstaller, but it seems to generate files executable only in a platform that is building the application(in this case, osx).
Is there easy way out like Pyinstaller or do I have to do that in a very complex way? Since I'm not the expert, the latter option might be impossible for me to do. Would it be more wise just to try to build the app on windows than mac using pyinstaller?
For pyinstaller, they have clearly mentioned that packaging Windows binaries while running under OS X is NOT supported, and recommended to use Wine for this.
1. Can I package Windows binaries while running under Linux?
No, this is not supported. Please use Wine for this, PyInstaller runs
fine in Wine. You may also want to have a look at this thread in the
mailinglist. In version 1.4 we had build in some support for this, but
it showed to work only half. It would require some Windows system on
another partition and would only work for pure Python programs. As
soon as you want a decent GUI (gtk, qt, wx), you would need to install
Windows libraries anyhow. So it's much easier to just use Wine.
2. Can I package Windows binaries while running under OS X?
No, this is not supported. Please try Wine for this.
3. Can I package OS X binaries while running under Linux?
This is currently not possible at all. Sorry! If
you want to help out, you are very welcome.
I am new to Qt and developing with python.
Would a python application developed using Qt framework and PyQt require the entire Qt framework to be installed on a user's machine in order to run a "exe" version of the application created with something like p2exe? Or would py2exe copy the required Qt framework components into the application that it creates?
I don't know what you mean by "frozen" but if your question is whether you can create an "exe" for a pyqt python script without installing python and pyqt on user machine then answer is yes. As with any other exe you don't need to install anything on user machine.
I have created a few application using pyqt and converted them to exe using pyinstaller-2.0 and it works fine on any machine. Same is true with py2exe.
Py2exe, when used with PyQt, will only copy the basics needed to get a Qt application to run. It won't copy the plugins that likely need. You need to take extra steps to install whatever image, platform, phonon, multimedia, etc. plugins you may need.
By basics I mean it will install the directly linked libraries from the Qt framework. Qt consists of a bunch of libraries. Some of those are linked directly into any executable using them (like the PyQt library), some of them are plugins. Py2exe will not copy those plugins, since it generally has no way of knowing which ones you may need. You need to let Py2exe know about the plugins your application requires: add them to the configuration file (setup.py).
No need for further install.
e.g. Py2exe will copy everything needed.
If you have some special requirement you may have to copy other stuff manually. In my application I copy some extra ddls, some ico files and some matplotlib files.
I hope my title was clear. I'm using wxpython for making a GUI and I want it to be able to be opened, extracted, and have it work on all operating systems. I was able to include twill by finding a folder called twill inside the twill archive, which worked fine. However, I'm unable to figure out how to correctly package wxpython.
EDIT: I'm not using either. py2exe is only for windows, and bbfreeze doesn't seem to work on mac (so it's not cross platform)
Unfortunately, there's just no one stop solution so that a single installable executable will work across all operating systems. The right solution is really to provide a different installer or executable for each OS; For windows, use py2exe, for mac, py2app is a good choice, and for linux you should just provide a tarball with a reasonable setup.py (that you will need for the first two, anyway).
You should go with the recommendation of TokenMacGuy. But I preferrably would use a tool which is able to freeze the application for all OS instead of using different ones.
cx_freeze is a good choice regarding these terms.
This is another fine alternative:
PyInstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, and Mac OS X. Its main advantages over similar tools are that PyInstaller works with any version of Python since 2.2, it builds smaller executables thanks to transparent compression, it is fully multi-platform, and use the OS support to load the dynamic libraries, thus ensuring full compatibility.
Have you tried http://cx-freeze.sourceforge.net/ ?
I have a scrapy project that I would like to package all together for a customer using windows without having to manually install dependencies for them. I came across cxfreeze, but I'm not quite sure how it would work with a scrapy project.
I'm thinking I would make some sort of interface and run the scrapy crawler with 'from scrapy.cmdline import execute', but I'm not sure.
Thanks in advance for any help.
Try out py2exe. It works well, you can bundle all the code in one exe.
I suggest you to exclude unused packages to reduce exe size (see py2exe examples on its site)
UDATE
As suggested try also
GUI2Exe is a Graphical User
Interface frontend to all the
"executable builders" available for
the Python programming language. It
can be used to build standalone
Windows executables, Linux
applications and Mac OS application
bundles and plugins starting from
Python scripts.