There are two ways to display line numbers in PyCharm:
1, Temporary Settings. Right-click at the line number and select Show Line Numbers.
However, this method only works for one file and disappears after restarting PyCharm.
2, permanent settings. File --> Settings --> Editor --> Appearance , then check Show Line Numbers.