You dont have to compile it. the first you use it (import) it is compiled by the CPython interpreter. But if you really want to compile there are several options.
To compile to exe
Or 2 compile just a specific *.py file, you can just use
import py_compile
py_compile.compile("yourpythoncode.py")