How do you remove Python2 and Python3 that comes with macOS? I have Python3 installed using Anaconda and would like to get rid of the original Python2 and Python3.
Simply put you cannot. You would damage the system and violate Apple's Gatekeeper security which protects system files. Gatekeeper would then restore those files if it did not already break the OS due to internal use of Python code and cause you to fail to boot.
MacOS is not designed to be a configurable OS. Frameworks that come with the OS are used by the OS, aside from those that reside in your Applications folder itself. Apple MUST have a version of all initially supplied frameworks present as the OS itself needs a backstop should your Anaconda install be removed. Any internal python code will be hard-wired (as in direct unmodifiable access) to those frameworks and will not use any others. Same with Java and such.
Your comment to the other answer however is your real question. You want to compile using non internal Python and I believe the way to do that is to change the PATH variable of Python to point to Anaconda's one.
export PATH="/Users/username/anaconda3/bin:$PATH" into .bash_profile or .zshrc will do it.
The #include headers are not where your Python location should be selected btw. It should either be in your IDE settings or directly in the variables you provide to the compiler on make.
You can't -- at least, not without breaking things. (Which I won't advise you on how to do.)
In macOS Mojave (10.14) and earlier, Python 2.7 is a core component of the operating system, and cannot be removed. Some parts of the operating system may depend on its presence; removing it is likely to cause incorrect behavior. Python 3, however, is not part of the operating system -- if it is present on your computer, it's because you installed it, or a piece of software which included it. How you remove it will depend on how it was installed.
In macOS Catalina (10.15), Python 2.7 remains a core component of the operating system, and Python 3 can be installed as part of the Xcode toolchain. (macOS Catalina is expected to be released in September 2019.)