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.
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've seen from some sources that although you can make an exe or mac equivalent app using py2exe or py2app, you can only make the one your system is. Makes sense when I think about it.
But my problem is sometimes I want to write python scripts and send them to my Windows-using friends to test and play with. But Windows doesn't come with python installed, and I don't want to make them have to install Python.
Is there any way to use a MAC to create a python-made file that can be opened without python or any installation ON WINDOWS?
If there's not I suppose I could try using the emulated Windows on my system to make it an exe, but I'd rather not boot that every time I need to change something.
You can't make a native py2exe-style executable on Mac. Use Virtualbox to run Windows inside your Mac environment. No need to reboot the whole machine.
Depending on how many dependencies you're willing to install on your machine (your friends with Windows shouldn't have any installation to do), another alternative would be to use IronPython. It won't compile all python code, but it works for a very large subset of it.
And the resulting .exe files can be run on your Mac using the Mono runtime, and on your friend's Windows system using the very likely already installed .NET runtime.
Here's what you would need to do:
Install the Mono runtime.
Install IronPython 2.7.2 or later.
Run mono ipy.exe pyc.py /main:your_program.py /target:exe /embed
This will produce a .exe file that can be run on Windows, Mac, and Linux. On your Mac, you'd do mono your_program.exe. On Windows, your friends can just double-click the .exe file if they have .NET 4.0 installed (very good chance that they do).
I recently built an application, for a client, which has several python files. I use ubuntu, and now that I am finished, I would like to give this to the client in a way that would make it easy for her to use in windows.
I have looked into py2exe with wine, as well as cx_freeze and some other stuff, but cannot find a straightforward tutorial or useful documentation for turning many python files in ubuntu into an easy-to-use windows application or executable or anything really.
Thanks!
This page appears to have a solution, as the asker didn't reply:
Install WINE.
Use WINE to install Python 2.3.
Use WINE to install py2exe.
Make a setup.py file for py2exe to compile your script:
from distutils.core import setup
import py2exe
setup(name="vervang",
scripts=["vervang.py"],
)
Run wine python.exe setup.py py2exe
This page says the resulting binaries might not be valid Win32 executables, though.
py2exe will not work on linux. Try pyinstaller it is a pure python implementation that will work on linux, mac and windows.
My friend does not have Python or the libraries needed installed on his machine to run a program I have written. Is there a simple way to export my project (currently sitting in pydev on my x64 Windows 7 machine) so that he could run it on his machine? (He has OSX, but he could find Unix or Windows if needed.) My program uses several modules, and depends on networkx, wx, and matplotlib.
Feel free to move this to programming if overflow isn't appropriate.
Thanks!
You could use py2exe (Windows), cx_Freeze (should work on any platform that Python itself works on) or py2app (Mac OS X).
OS X actually already has python installed, albeit a somewhat old version. On OS X, a great solution to getting newer python Mac Ports package manager.
On Windows, python has an installer, and many of the most popular modules also have installers that respect the installed python. Alternatively, you can use Cygwin to install X-Windows versions of same.
On unix like platforms, well, you're already good to go. Python is preinstalled on just about every distro, and the package manager will have all of the popular modules ready to install, too.
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.