Django 1.10 및 Python 3.5에서 MariaDB 사용
SQLite에서 MariaDB로 데이터베이스를 마이그레이션하고 싶습니다.Ubuntu 14.04, Django 1.10 및 Python 3.5를 실행합니다.Digital Ocean에는 가이드가 있지만, 3.x가 아닌 Python 2.x를 사용하고 있다고 묵묵히 가정하고 있습니다.기본 MySQL 커넥터인 MySQLdb를 사용합니다.이것은 python 3.x에서는 동작하지 않습니다.Django docs에 따르면 권장되는 대체 방법은 mysqlsclient입니다.
pip install mysqlclient
단, 다음과 같은 이점이 있습니다.
Collecting mysqlclient
Using cached mysqlclient-1.3.9.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
Complete output from command /django/env/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3_5btd8o/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp39x31avopip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.5/MySQLdb
creating build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.5
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,9,'final',1) -D__version__=1.3.9 -I/usr/include/mysql -I/usr/include/python3.5m -I/django/env/include/python3.5m -c _mysql.c -o build/temp.linux-x86_64-3.5/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
_mysql.c:40:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /django/env/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3_5btd8o/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qfim2s5n-record/install-record.txt --single-version-externally-managed --compile --install-headers /django/env/include/site/python3.5/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.5/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.5/MySQLdb
creating build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.5/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.5
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,9,'final',1) -D__version__=1.3.9 -I/usr/include/mysql -I/usr/include/python3.5m -I/django/env/include/python3.5m -c _mysql.c -o build/temp.linux-x86_64-3.5/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
_mysql.c:40:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/django/env/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3_5btd8o/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qfim2s5n-record/install-record.txt --single-version-externally-managed --compile --install-headers /django/env/include/site/python3.5/mysqlclient" failed with error code 1 in /tmp/pip-build-3_5btd8o/mysqlclient/
왜 부분적으로만 복제됐는지 모르겠어요
이 질문에 따르면, 그 해결책은x86_64-linux-gnu-gcc
에러는, 인스톨:
sudo apt install libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev
그랬지만, 이것 때문에 달라지진 않았어요.
그리고 나서 나는 다음을 포함한 많은 것들을 시도했다.
sudo apt-get install libmysqlclient-dev python-dev
그 결과:
libmysqlclient-dev : Depends: libmysqlclient18 (= 5.5.52-0ubuntu0.14.04.1) but 5.5.52+maria-1~trusty is to be installed
E: Unable to correct problems, you have held broken packages.
라는 답을 찾아냈다.aptitude
보다 편리하다apt-get
또한 다음과 같은 패키지의 목록을 볼 수 있습니다.
dpkg --get-selections | grep hold
그러나 이 작업을 실행해도 아무것도 반환되지 않습니다.적성을 시험하는 것은 다음을 얻을 수 있습니다.
(env) user@computer:/$ sudo aptitude install libmysqlclient-dev
The following NEW packages will be installed:
libmysqlclient-dev{b}
0 packages upgraded, 1 newly installed, 0 to remove and 179 not upgraded.
Need to get 0 B/866 kB of archives. After unpacking 5,604 kB will be used.
The following packages have unmet dependencies:
libmariadbclient-dev : Conflicts: libmysqlclient-dev but 5.5.52-0ubuntu0.14.04.1 is to be installed.
Conflicts: libmysqlclient15-dev which is a virtual package.
libmysqlclient-dev : Depends: libmysqlclient18 (= 5.5.52-0ubuntu0.14.04.1) but 5.5.52+maria-1~trusty is installed.
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libmysqlclient-dev [Not Installed]
mysql 기반 패키지와 mariaDB 기반 패키지 간의 충돌로 보입니다.그래서 알게 된 건졌다.
pip install libmariadbclient-dev
설치는 정상적으로 완료되지만 mysqlclient를 설치하려고 할 때 아직 오류가 발생합니다.
MariaDB를 Django 1.10 및 Python 3.5와 함께 사용하려면 어떻게 해야 합니까?
실행하는 동안 같은 문제가 발생했습니다.
pip install mysqlclient
그 후 python3-dev 패키지를 설치해야 하는데 python3.6으로 해결되어 virtualenv에서 python3.4를 사용하고 있었습니다.
내가 해야 할 일은
sudo apt-get install python3.4-dev
언급URL : https://stackoverflow.com/questions/39810798/using-mariadb-with-django-1-10-and-python-3-5
'source' 카테고리의 다른 글
PHP: 배열에서 특정 요소를 제거하려면 어떻게 해야 합니까? (0) | 2022.12.24 |
---|---|
MySQL Workbench에서 전체 데이터베이스 스크립트를 생성하는 방법 (0) | 2022.12.24 |
utf8_general_ci와 utf8_unicode_ci의 차이점은 무엇입니까? (0) | 2022.12.24 |
관계가 없는 2개의 테이블에서 선택 (0) | 2022.12.24 |
MySQL에서 다른 테이블과 일치하는 테이블을 생성하시겠습니까? (0) | 2022.12.24 |