---
# System prepended metadata

title: Python - compile python file manually
tags: [python]

---

# Python - compile python file manually

###### tags: `python`

A python script file is not used as an import, it will not going to create ".pyc" file when execute the script.
So use "py_compile" module to compile your python script manually.
```
>>>import py_compile
>>>py_compile.compile('script file name')
```
Then it will output .pyc file of python source script.

Another method using python command
```
python -m compileall <filename>
python -O -m compileall <filename>
```
