The thing with Python is, that it is a bytecode language, this means that Python in itself is very difficult to lock/obfuscate. The reason why it is so hard obfuscate code written in Python is because the language from the ground up was designed to be open source, so anyone skilled enough has an easy way to reveal or modify Python related stuff, not just code but the interpreter itself. There are some ways to "protect" code in Python such as pyc or pyo but even scripts protected with such packages can be reverse engineered by an experienced user.
So, my suggestion is, if the security of your code is your number one priority then maybe Python is not the ideal tool for you. But if you must use Python in your project by one reason or another then I'd suggest you to read Protecting a Python codebase, it explains the pyc and pyo methods that I mentioned before and also explains a method using a static compiler for Python called Cython. That is the most helpful document I could find, I hope it helps with your project.