0

So I am a beginner to python programming and pretty much programming in general. But I am having fun writing programs in python and want to be able to send my friends(who have no computer knowledge) my file and basically have them double click it and it just runs. The program is just a text-based question and answer thing. My friends would have mac and windows so it needs to work on both.

Note: I did read something about batch files? If that is the answer, please explain how those work and what they are or point me to some good resources.

Note: I am doing this on a mac but again it needs to work on mac or windows (and/or Linux too bc why not lol)

EDIT: Please do not just mark this as a duplicate. Most answers on here are for python 2.7, and use lots of jargon I do not understand. Please use very simple terms to explain this. I do not want to use third party software, I want to LEARN how to program it to do this myself.

Thanks everyone!

Dan
  • 451
  • 3
  • 13
  • That doesn't seem updated for python 3. – Dan Oct 04 '17 at 13:14
  • You can absolutely use PyInstaller on Python 3. – SomethingDark Oct 04 '17 at 13:18
  • Why do people just downvote this with no explanation? Isn't this site supposed to he HELPFUL? – Dan Oct 04 '17 at 13:18
  • lol who told you that? – SomethingDark Oct 04 '17 at 13:19
  • -_- is it really difficult to write a program that does this? Why does everyone use third party programs to do it? – Dan Oct 04 '17 at 13:20
  • The reference Python implementation (i.e. the version you can download from python.org) compiles and executes Python source code as bytecode -- not as a native platform executable. That's why we have freezing frameworks such as PyInstaller -- to distribute the interpreter, DLL dependencies, packages, and scripts bundled in an executable. It's not required for systems that already have the Python interpreter installed. In that case you can use [zipapp](https://docs.python.org/3/library/zipapp.html). But Windows doesn't come with Python pre-installed, so zipapp doesn't help. – Eryk Sun Oct 04 '17 at 15:06
  • no way I can understand this. Where can I go to read about all this in SIMPLE terms? What is byte code specifically? – Dan Oct 04 '17 at 15:09
  • And i am on mac and python just works. I don't have to do anything. Does that not hold true for windows? Is that where the issue is? – Dan Oct 04 '17 at 15:09
  • Bytecode is a compiled form of pure Python code that the interpreter executes, as opposed to native machine code instructions that a CPU executes directly. The CPython interpreter is compiled to native machine code, which the bytecode is 'scripting'. Take a look at disassembled bytecode by defining a function `f` and calling `dis.dis(f)`. Read the [docs](https://docs.python.org/3/library/dis.html) for an explanation of each operation. – Eryk Sun Oct 04 '17 at 18:34
  • 1
    Yes, Python is not pre-installed on Windows, so your friends that use Windows would have to install it before they could run a .py script or zipapp script, and installations don't always go smoothly. But that step isn't necessary if you create a frozen executable with something like PyInstaller or py2exe. – Eryk Sun Oct 04 '17 at 18:36
  • Ok cool. What does "frozen" executable mean? @eryksun – Dan Oct 04 '17 at 18:37
  • Think of your package being in a 'thawed' state when it's spread over multiple directories -- i.e. the interpreter, site-package dependencies, dependent DLLs and extension modules, your own scripts and subpackages. A frozen executable packs all of that into (potentially) one file. The first part of a 'frozen' executable is a binary loader that's executable (e.g. on Windows it's a 32-bit or 64-bit PE executable), which has code to unzip and unpack the interpreter, your script, and its dependencies to a temp directory and then execute it. – Eryk Sun Oct 04 '17 at 18:58
  • That is super cool. I kinda was under the impression all files should be like that separately. Any good resources for all this stuff? Other than google? Lol @eryksun – Dan Oct 04 '17 at 19:00
  • Visit the [PyInstaller](http://www.pyinstaller.org) website for more information. – Eryk Sun Oct 04 '17 at 19:05

0 Answers0