0

There is a pyz file that has all the dependency bundle I need (numpy, tensorflow....etc)

I am wondering how do I run a function inside that pyz file.

For example if there is a function called runJob

I would like to call that function in my script

import function_from_pyz
if __name__ == "__main__":
    funciton_from_pyz.runJob()
    

The following doesn't quite work

<python path> my_pyz_file.pyz myscript.py
olaf
  • 239
  • 1
  • 8

1 Answers1

0

A .pyz file is just a normal zip with a header that allows it to be executed. Python can import modules from a zip file exactly like from a subdirectory.

So, if the function is in a file called __main__.py, you just do:

from my_pyz_file.__main__ import runJob
Tim Roberts
  • 48,973
  • 4
  • 21
  • 30