Python in mac and Windows - python

Is there any difference in python in both except different operating systems?
I mean if i create a python script in windows, will it run the same in mac too? As long as there is same versions of python in both?
My concern is that I don't have any mac devices to try to run it on so just making sure that I am not doing anything wrong.
Thank you for your help :)

There is no difference.
Python can run on both systems. However, you may be using a module that only works on Windows (e.g. win32api). You can check your module's compatibility on a virtual machine.
If you would like to compile into an application (.exe or .app extension), you will need to use py2app and py2exe which requires you to be on the os respectively. In this case, I suggest that you consider Java or Jython since they are cross platform.

There absolutely no difference between OS. Its a programming lang, only difference would be the IDE you decide to use. Other than that, the way it give O/P to programs is same. Hope it solves your doubt.

Found this discussion revelant to your question. Hope it helps.
https://www.quora.com/Can-I-run-my-Python-program-in-both-Linux-and-Windows

Related

Run Galde Gtk3+ Python under Windows

i've created a student-managing-software for linux which use different packages (tkmessageboxes, glade-builder, gtk3+). Now, there are a lot of people how asked how it can be used under windows but i've no idea. So, does someone know how to use these packages under windows or is it impossible? THX
Well I would say it is up to the developer to make an actual installer for it, but you can get all of the dependencies through the MSYS2 project.

will python code written in windows work in linux?

I would like to write some Python code in Windows using QtPy. But before I do that I'd like to know that I can use the code I wrote in Python. I understand that the complied program won't work due to different platforms but will there be any issues with regards to the *.py files I write in windows vs linux?
I've been trying to install QtPy on my Mint installation and I just don't know what the problem is. Which is why I wanna go this route.
I'd also like my code to work on the raspberry pi.
Could you guys advise me to this end?
Thanks!
Mostly, yes, as long as you keep to using the tools Python provides you and don't write code that is platform specific.
Use os.path.join() to build paths, for example. Open files in binary mode when you deal with binary data, text mode when it's text data. Etc.
Python code itself is platform agnostic; the interpreter on Linux can read python code written on Windows just fine and vice versa.
The general rule of thumb is to pay attention to the documentation of the modules you are using; any platform specific gotchas should be documented.
It depends on what your code does. Most packages work in both windows and linux however some such as signal only work in windows and are not portable. But in the python docs it will say what platforms a given package works in.

Is it possible to generate an executable for Windows using bbfreeze (python) on a Linux platform? If so, how?

There is a related question. The answer there suggests using PyInstaller. I'm looking at PyInstaller documentation. In the meanwhile, if somebody could specify how this could be done using bbfreeze that would be great, since we already have a deployment system in place that uses bbfreeze.
It is not terribly likely. If I were you I would try to use the Windows PY2EXE inside WINE. If it works, you are golden, if not head to your local used laptops flea market and get an old Windows XP machine to do the job.

Releasing a wxPython App: Give out scripts or compile in Exe, etc?

I have a wxPython application that is almost done & I would like to place it in my portfolio. I have to consider when someone attempts to run my app that they may not have Python, or wxPython, so if they just click the main script/python file its not going to run, right?
How should I distribute my app (how do you distribute ur apps) so that it can be run & also so that it could be run on the 3 major OS's (Unix, Windows, MacOSX)?
I know of py2exe for releasing under windows, but what can I use for Unix & MacOSX to compile the program? Whats the easiest way?
Use Gui2exe and compress with UPX to get unpacked size down.
For a setup file(exe) with uinstall info Inno-Setup is good.
I have use this with wxpython several times and got it to work on all windows versions.
For Gui2exe use optimize(2) - compressed(2) - Bundle files(3)
Bundle files(3) is the most stable,
Bundle files(1) make one big exe-file.
For one exe-file is better as last step to use Inno-Setup
You can use py2exe for Windows and py2app for Mac. PyInstaller works for Windows and Linux. Personally, I use GUI2Exe, which wraps all three and makes them a little easier to use. Note: I don't have a Mac, so I haven't tried it with that. You can check out my series on freezing Python here:
http://www.blog.pythonlibrary.org/2010/08/10/a-pyinstaller-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/
http://www.blog.pythonlibrary.org/2010/08/31/another-gui2exe-tutorial-build-a-binary-series/
There are a couple others on the blog too.
I suggest both, script for all platforms and frozen binary for lazy windows users.
To answer your latest question, you don't compile python. Python is an interpreted language, it gets compiled on the fly when run. A python frozen binary is actually the python interpreter with your script hardcoded in it. And frozen binaries are windows-only, AFAIK. Besides, Unix and MacOS (usually) come with python pre-installed.

Micropython or minimal python installation

I once read about minimal python installation without a lot of the libraries that come with the python default installation but could not find it on the web...
What I want to do is to just pack a script with the python stuff required to execute it and make portable.
Does any one know about something like that?
Thanks
Micro Python is actively maintained and has been ported to a bunch of microcontrollers.
For other small implementations, you might also want to check out tinypy or PyMite.
If you don't care about size, but really just want an easy way to distribute a python program, consider PyInstaller or one of the others on this list.
Portable python might do what you want. It's a python installation for USB thumb drives.
There's now finally Micro Python, claiming to be full reimplementation of Python 3 core, fitting even into medium-size 32bit microcontrollers. API will be different of course, so C modules will require porting. Project is funded via KickStarter, source code will be released some time after the campaign (request for consideration was made to author to not delay release of the source, to help bootstrap Micro Python community sooner).
http://micropython.org/
You can also look for already installed instances.
OpenOffice / LibreOffice
Look at the environment variable UNO_PATH or into the default install directories, for example for Windows and LO5
%ProgramFiles(x86)%\LibreOffice 5\program\python.exe
Gimp
look into the default install directories, for example for Windows
C:\Program Files\GIMP 2\Python
and so on...

Categories

Resources