When I want a user in Python3, from terminal
sudo su
python3
>>> import getpass
>>>getpass.getuser()
'root'
how can I get the normal username?
If you are running the script interactively, you should be using sudo to run it and os.getlogin() will give the correct user.
sudo why because I running on root userI recommend the os.getlogin() from @bromate's answer.
Here is another way:
import os
user = os.environ['SUDO_USER'] # KeyError if not run under sudo