1

Is it possible to run python bytecode files without the need of the C Python interpreter to be installed on the host OS ?

6
  • Bytecode is just code for the interpreter. It is not machine code that can be run directly. Note that the bytecode tag even says "the CPython interpreter runs bytecode stored in .pyc files." Commented Jun 29, 2020 at 19:20
  • Python "bytecode" is not the result of a compilation process. It is the result of the expensive parsing process stored in an interpreter friendly binary format. Commented Jun 29, 2020 at 19:21
  • @KlausD - .pyc files are a header plus a marshaled code object which has already been compiled. Commented Jun 29, 2020 at 20:22
  • @tdelaney Compiled in a broader meaning of the word. Not compiled as a compiler would do for example for C code. Commented Jun 29, 2020 at 20:38
  • 1
    @KlausD. - We could debate what "interpreter" means, but python compiles source into byte code and then executes the byte code in the "python virtual machine". It does what the java compiler does to java source. And pretty much what the C compiler does, except the target is byte code, not machine code. Because its dynamic it doesn't need things like C header files or external java class definitions, but its still a compiler. Commented Jun 29, 2020 at 20:52

1 Answer 1

2

No, python interpreter is required.

You can use apps such as pyinstaller to make a executable of your scripts so that all required packages and python libs including the interpreter is self contained in a single executable. It runs like any other programs so nothing else needs to be done except double click and run.

Also .pyc files require the specific version of python to run with which they are compiled so it is really not a recommended way of distributing python code if thats what you are planning.

This answer has more details: https://stackoverflow.com/a/36027342/4289062

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.