Python 에러 해결, AttributeError: module 'jwt' has no attribute 'encode'

파이썬에서 jwt 라이브러리를 사용하는 스크립트 실행 중 에러가 발생하였고, 해결 방법을 정리합니다.

1. jwt error

아래와 같이 jwt.encode() 함수를 실행할 때 encode 속성이 없다는 에러가 발생하였습니다.

AttributeError: module 'jwt' has no attribute 'encode'

jwt error in python

2. 문제 원인

PyJWT 라이브러리를 사용했어야 했는데, 실수로 jwt 라는 다른 라이브러리를 설치했었습니다. 즉, 라이브러리를 잘못설치해서 발생한 문제였습니다.

3. 해결 방법

먼저 pip로 이름이 비슷한 잘못된 라이브러리를 삭제합니다.

$ pip uninstall jwt
$ pip uninstall JWT

그 다음에, pip로 PyJWT를 설치합니다.

$ pip install PyJWT

설치 후, 다시 프로그램을 실행해서 문제가 해결되었는지 확인합니다.

Loading script...

Related Posts

codechachaCopyright ©2019 codechacha