How can I manually generate a .pyc file from a .py file
python
Solution
You can use `compileall` in the terminal. The following command will go recursively into sub directories and make pyc files for all the python files it finds. The compileall module is part of the python standard library, so you don't need to install anything extra to use it. This works exactly the same way for python2 and python3.
python -m compileall .
Problem
For some reason, I can not depend on Python's "import" statement to generate .pyc file automatically Is there a way to implement a function as following? ``` def py_to_pyc(py_filepath, pyc_filepath): ... ```