2-factor authentication code generator in Python 3
Code quality


Each import should have its own, seperate line:

import hmac
import base64
import struct
import hashlib
import time
import pyqrcode
import random
import sys
import os

Top-level functions should be seperated using two blank lines:

def foo():
    foobar()


def bar():
    foobar()

A lot of your comments should actually be docstrings.


Security


Don't use the random module for security purposes. Skimming through the documentation, red banners warn you not to use it for security purposes and instead to use the secrets module. Note that secrets is only part of the standard library in Python 3.6 and upwards. If you need to run this on other versions of Python, which is quite likely, make use of random.SystemRandom (or os.urandom() directly).
Use getpass.getpass() instead of plain input() for gathering secrets like passwords or private codes. [getpass documentation]


General recommendations


Since pyqrcode isn't part of the standard library, you may want to wrap import pyqrcode in a try:/except: statement:

try:
    import pyqrcode
except ModuleNotFoundError:
    print("Couldn't import pyqrcode.")
    sys.exit(1)

If you plan to release this as a module, it's a very good idea to add documentation (docstrings, as well as a README for quick reference), so others understand how the code works and how they should use it.