에러
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
변수 선언했던 int(os.getenv('TEST')) 소스에서 에러 발생
class MainProcess():
test = int(os.getenv('TEST'))
증상
리눅스에서 실행할 때 에러
python main.py 했을 때 에러
python vscode launch.json으로 실행 시 에서는 에러 없음
원인
vscode에서 launch.json 통해 실행 시 .env를 자동으로 찾아서 로드해주지만
그냥 실행하면 안 해주기 때문이다.
해결
dotenv.load_dotenv() 선언해줌으로서 해결 완료
import dotenv
logger = Logger.getInstance()
dotenv.load_dotenv()
class MainProcess():
test = int(os.getenv('TEST'))
비고
init 에 getenv 선언할 때는 이런 문제가 없었다.
init 위에 클래스 변수로 했을 때 발생..
정확한 원인은 무엇인지 나중에 알아보자.
결국 getenv를 쓰는 곳에 전부다 dotenv 선언이 필요하다는 말씀!