본문 바로가기
DevSpace/Python | Django

[Django]mysqlclient 설치 후 django runserver 실행시 에러

by 반니루니 2019. 12. 2.
반응형

앞서, python-django 와 mysql연동을 위한 mysqlclient 설치시에 에러발생으로 포스팅을 했었습니다.

https://toentoi.tistory.com/49

 

[Python-Django] mysqlclient 설치시 오류

#Python 버전 : 3.7 #Django 버전 : 2.2.7 Python 및 Django 설치 후 아래와 같이 error : command 'x_86_64-linux-gnu-gcc' failed with exit status 1 에러 문구가 발생합니다. sudo apt-get install python3 p..

toentoi.tistory.com

허나 설치 후 적용하여 runserver를 하려고 하면 아래와 같이 에러문구가 발생합니다.

 

#mysqlclient 1.3.13 or newer is required you have 0.9.3

 

mysqlclient를 1.3.13이상으로 업그레이드 하라는 문구

하여, mysqlclient 1.3.13으로 업그레이드하려 했으나 최신버전이 0.9.3인것 같더군요...

 

Django의 정책인것 같아서 구글링해보았습니다.

 

역시나 구글링해보니, Django의 초기세팅이 1.3.13버전이상만을 사용하게 끔 되어있었습니다.

 

출처:

https://stackoverflow.com/questions/55657752/django-installing-mysqlclient-error-mysqlclient-1-3-13-or-newer-is-required

 

Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3

I've trawled the forums but cannot find an answer or even any documentation on this. On running the command: python manage.py inspectdb I get the error: mysqlclient 1.3.13 or newer is required;...

stackoverflow.com

 

해결방법:

django가 설치된 디렉토리 > lib/python3.6/site-packages/django/db/backends/mysql 

폴더로 이동하셔서 base.py 파일을 vi혹은 vim 에디터로 오픈합니다.

 

base.py 오픈

 

raise부분을 pass로 변경해줘야 합니다.

version =Database.version_info 아래부분을 확인 후 변경해 줍니다.

 

raise > pass 변경 후 문법에 맞게 '''를 입력해줍니다.

수정

 


if version < (1, 3, 13): pass ''' raise ImproperlyConfigured( 'mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__ ) '''

 


위와 같이 저장 후 같은 디렉토리의 operations.py 파일을 오픈합니다.

 

한 군데 더 수정해줍니다.

 

query= query.decode(errors='replace')   ==> query= query.encode(errors='replace')

 

@vim 검색은 :/decode 라고 검색하시면 편하게 찾을 수 있습니다.

decode 검색후 encode로 수정

저장 후 runserver 시키시면 정상적으로 서버가 실행될 것입니다.

반응형