TypeError:使用Python 3.7时,int()参数必须是字符串,类似字节的对象或数字,而不是“ NoneType”

我正在尝试运行下面的简单片段

port = int(os.getenv('PORT'))
print("Starting app on port %d" % port)

我可以理解PORT是s字符串,但是我需要转换为int。为什么我得到错误

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'