PyQt5 on MacOS X Mavericks †. This article introduces PyQt and explains how to install PyQt5 on Mac OS X Mavericks 10.9.5. This shows how to build Qt for OS X and bind to Python with PyQt. Print ( 'Hello World!' ) Then, in order to create the executable just run python pyinstaller.py myscript.py and you will see a lot of output and a folder called myscript will be created, with two folders and a file inside. The build folder is used by PyInstaller as a temporary folder to create the files needed for the executable. The dist folder stores the executable and all of the files needed in order to run that executable. It is safe to delete the build folder. The file called myscript.spec is useful to customize the way PyInstaller packs your application. Now test if your executable works: • •. Python pyinstaller. Py -- windowed tkexample. Py In this moment you can navigate to the dist folder and run the application by double clicking it. Note for Mac OS X users: the above example using Tkinter works fine if you use the pre-installed Python version, if you installed or updated Python by yourself, you can find some problems running the packaged application. Using External Modules The previous examples were importing modules from the Python Standard Library. PyInstaller includes the Standard Library Modules by default. ![]() However if we installed a third party library, PyInstaller is likely not to include it. In most of the cases we need to create 'hooks' to tell PyInstaller to include these modules. Google chrome. An example of this is an application using the ReportLab library to make PDF files. ] Now in order to pack the executable, we have to run python pyinstaller.py --additional-hooks-dir=hooks/ invoice.py. The additional-hooks-dir flag tells PyInstaller to search for hooks in the specified directory. Conclusion Pyinstaller works great if your script only imports modules from The Python Standard Library, or a module included in the official list. Using these supported packages make packaging applications pretty straightforward, but when wee need to use a third-party not supported module, it can be tricky to make it work.
0 Comments
Leave a Reply. |