I don’t know if look at my code is going to help as it will have lots of irrelevant stuff.
If you have the error at ‘import serial’, then this is likely a python library conflict. If you running your python code without an virtual environment, this is bad practice as the more python libraries your install the more likely conflicts will occur (it is inevitable actually) because not all versions of libraries are compatible each other.
I recommend you use an virtual environment manager like Anaconda. Research it if you don’t already know about it. With Anaconda, you can create virtual environment in whatever python version and install only the libraries necessary. You create virtual environment for each particular python thing you need.