What can I do about a python SyntaxError when generating project files?

When I click Refresh Visual Studio Project I see the following error in my Output Log:

Running C:/Program Files/Epic Games/UE_4.19/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project=“D:/dev/projects/pirates/udemy/S3/S3.uproject” -game -rocket -progress

Discovering modules, targets and source code for project…

File “C:\Program Files\Python36\Lib\site.py”, line 177

file=sys.stderr)

    ^

SyntaxError: invalid syntax

The ^ is pointing at the equals sign in `file=sys.stderr.

When searching I found several references that say that I’m running the wrong version of Python, but there is only 3.6 on my system (3.6.6 is on the path and I see an Anaconda install of 3.6.5 in Windows Programs menu).

What is this error and how can I fix it?

Note that as far as I can tell, nothing is broken, but the error is annoying and I might’ve missed the actual problem as of yet.

Additional question: What does the engine do with python?

As it turned out, I had an installation issue with python. I noticed this problem when Blender would not start up. Again site.py was generating an error. When searching around I found stuff that suggested an old python executable could be in use. So I removed my python installations (both from manual install and the stuff that I got from Visual Studio). This fixed the error for both Blender and Unreal Engine.
Now I only have to reinstall python in a way that won’t break everything again.