it has been a while now I'm surfing the net trying to find the way to sucessfully install PyQt4 on different Mac OS's and I can't figure it out.
Does anybody know if there is out there a package I could easily install without having to go through the compiling?
I'm developing sone Python tools with PyQt guis and the idea is to be able to make them work on multy pltaforms.
Any hit would be gratly apreciated,
Cheers,
Lozo
Take a look at py2app. It will bundle up a python script as a Mac OS .app bundle. Inside of there, if configured correctly, will be the copies of the PyQt and Python modules needed to run the program.
For packaging for running on Windows, there's py2exe. Likewise, if configured correctly, it will handle copying all of the libraries into the directory the .exe is made.
From this point on either Mac or Windows, you can create an installer program, .dmg, etc., to distribute and install PyQt applications onto these platforms without having to worry about the end user having to build their own copies of PyQt.
You can install PyQt4 from PyPM Index.
Install libraries from QT and then use Homebrew to install pyqt (google is your friend). I suggest looking at this site for a tutorial on Mac OS X Lion.
Related
I admit at the beginning that I am a novice python developer, so I apologize in advance for questions that may seem stupid.
I prepared python script with GUI (Tkinter), which use plenty external libraries. I'm working on Windows. Currently, I share my program in the form of an .exe file for Windows users, who do not have Python installed on their PCs. Everything works.
Recently I received a query if I can compile my code on an executable file that is usable for Mac users.
I have a number of questions related to this:
1) can I do it from a PC with Windows or i need Mac? I guess I have to have access to a Mac.
2) will my code work on mac without any editing? What about external libraries? Do you know any easy way to copy/paste my "python with used libraries" from Windows to Mac?
3) will I create a executable file in the same way as Windows, I mean I will use a "Pyinstaller" type library?
Thank you in advance for your help.
1) can I do it from a PC with Windows or i need Mac? I guess I have to have access to a Mac.
You can use a virtual machine and build for mac.
2) will my code work on mac without any editing? What about external libraries? Do you know any easy way to copy/paste my "python with used libraries" from Windows to Mac?
Some libraries have different behavior between macOS and Windows, yes. You should consult the documentation for the libraries you are using.
3) will I create a executable file in the same way as Windows, I mean I will use a "Pyinstaller" type library?
If you're actually using pyinstaller then it is compatible with both mac and windows. You have to check that the library you're using is compatible with both by looking at their docs.
An example of this is to use virtualbox mac image.
Install virtualbox (see this)
Install MacOS (see this)
Install the correct python (obviously python.org)
git clone your repository
Setup your virtual environment (or just pip install -r requirements.txt with your requirements file but I'm a stickler about venvs)
Note: I know you said pyinstaller-like but pyinstaller has a note about macos.
Build!
You shouldn't have any trouble. Just make sure the version of python is the same, as I believe the default on mac is 2.7.
Also, python scripts aren't compiled, rather interpreted, so making the file executable doesn't really mean it's a binary file in this case. I'm not sure what method you used to run python on a computer that doesn't have python on it, as there are a few, but if you can manage to do that on windows, it should work on mac.
I am able to compile a python script into a mac OS application using py2app, however it only runs on os 10.12 (which is what I am running).
From what I gather, this has something to do with the deployment build (MACOSX_DEPLOYMENT_TARGET) selected. I know this is an option in Xcode, but after hours of searching I can't seem to figure out how to change this when compiling using py2app.
Any help is greatly appreciated!
Have a look at Tweaking your Info.plist.You need to specify what platforms the application will run on otherwise it will default to the runtime libraries for current OSX release.
You do need to take care w.r.t. C extensions, those might pick up
dependencies on the current OS while building (in my experience that's
mostly a problem with some C libraries with a configure script that
detect C functions to use). The easiest way to avoid those problems is
to build wheels for C extensions on 10.10 then install those on the
Sierra machine.
Also you can see this issue.Hope this helps.
I'm trying to install kivy to make an application for android and ios.
I have installed the portable app as per the website but wanted to have it included in my python Idle.
So I searched and found Kivy-1.8.0.win32-py3.4.exe installs it ontop of your python instalation (C:\python34)
When i try and import i can import kivy but it wont let me install App or recognise UIX.
I have looked around and I think that my issue is with pygame, every time i try to install it i get missing files and that is with pip and a pygame-1.9.2a0.win32-py3.2.msi that i found but still nothing!
Also read it might be cython and i installed that too downloading Cython-0.21.1 andtrying to run the instaltion on that.
Is there a way to get this done without a headache?
Do i need kivy to make an app for android and ios or can i use tkinter? (thats works on my pc lol)
please any advice would be great, I have searched but all the information out there is very disjointed and im hoping to find a one stop answer in one of you guys.
thanks
Raif
Do i need kivy to make an app for android and ios or can i use tkinter? (thats works on my pc lol)
You need kivy (or maybe some other python tools, but I don't think any are remotely as good). The android build tools only work on linux or osx, though you can use a virtual machine for it.
If you installed from the popular unofficial windows binaries site, make sure the version matches your python version, and you probably need to get pygame from the same place. I don't know much about this though.
Linux is the best python development environment. Python on Windows is very very buggy with certain packages due to compatibility issue. Many important development packages in python are optimized for Linux. You get rid of all headache by downloading and installing a lightweight Linux like o. So like back box on a virtual machine.
If your goal is a Kivy app for iOS and Android, you have already made several mistakes. The first is that you cannot create an iOS app from any OS except OSX. There's no way around that. The second is that the tools for compiling for Android and iOS only work with Python2.7 currently. You seem to be using Python 3.4.
Background:
I'm writing a non-commercial application in Python, that uses wxPython, and depends on pyPortMidi and SciPy (both available on PyPi). I would like to share this with a small circle of Mac users - who live in different countries.
I work on Ubuntu, and don't have access to OSX systems for testing.
What I'm looking for:
A end-user friendly means of deploying my application, especially given the dependencies
What I've found so far:
Like Ubuntu, OSX comes with it's own Python bundled
This answer
suggests py2app. However, it's not clear from the
documentation
whether I can build an OSX app on an Ubuntu platform. Ditto with cx-Freeze.
Specific Questions:
Can I use py2app to build an OSX app on Ubuntu? And will it automagically include the above dependencies, or do I need to specify it somehow?
If not, can I write some sort of OSX script that will install the package dependies (using easy install, perhaps), painlessly on the end-user system? I haven't used distutils before, and I'm unfamiliar with OSX scripting, so any pointers would be appreciated!
Apologies for the noob questions, and thanks in advance.
You can use py2exe for Windows
Freeze on Linux and as you say py2app for Mac
py2app doesn't work on non-mac machines. As suggested by #victor-castillo-torres, have a look at Freeze, as also suggested in the linked mailing list.
Py2app only works on OSX systems, the code does not support building
bundles for other platforms than the one it is running on. That
is, py2app uses the currently running python installation to build a
depedency graph and copies the files mentioned in that graph to the
application bundle.
From the point of view of building script to install the dependencies
for your script OSX is just like any other Unix system, but with
different GUI libraries. A script that uses easy_install to install
dependencies could be made to work, although I don't know if all your
dependencies are easily available that way (in particular wxPython).
i wrote a program using python with PyQT4 and other modules like numpy, scipy etc. under Linux(Ubuntu 9.10). Now i want a executable of this program under Windows 7. I dont want to install Python on the Windows 7 OS.
i try pyinstaller, cx_freeze and py2exe under linux, but i generate only a linux executable which works fine under linux but not working under Windows.
Now my Questions are.
Is my Task possible or need i to install Python and the needed packages on Windows 7 to generate the executable with pyinstaller for examble?
if it is possible--> how is the solution to solve the problem.
regards lars
I only have experience with py2exe and pyqt4, but py2exe needs several dlls which can only exist inside a Windows environment (like Visual C runtime libs or the dlls for Qt). It might be hackable with Wine, but having a Windows environment for packaging everything is the "supported" way.
PyInstaller's Supported Packages page lists PyQT4 as supported so I'd give that a try - just get your application running as a conventional Python application under Windows 7, then run PyInstaller as usual. From personal experience I know it'll handle matplotlib, NumPy and SciPy without a hitch.