How to compile Python to DLL or alternative?

you can try py2exe, pyinstaller:

Step 1. pip install pyinstaller.

step 2. new python file let's name it code.py .

step 3. Write some lines of code i.e print("Hello World")

step 4. Open Command Prompt in the same location and write pyinstaller code.py hit enter. Last Step see in the same location two folders name build, dist will be created. inside dist folder there is folder code and inside that folder there is an exe file code.exe along with required .dll files