First, sorry if my question is not clear or is too simple, but I'm getting confuse about it. I have an EC2 instance where I want to run some python code previously developed in my computer. I want to automatically install all the packages that the python script use instead of doing pip in my EC2 instance for every package. I don't know if I need to use Docker, create a repository in GitHub and then clone it from my EC2 instance, or there is another alternative.
You have a few options to go about it.

Setup bootstrap to install your packages when you stand up a new EC2 instance.
create EC2 instance from image, using docker or with aws AMI.

This will setup an EC2 instance with all the dependency packages ready.
Automatically install python modules in EC2