Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将MariaDB与Django 1.10和Python 3.5一起使用_Python_Django_Ubuntu_Mariadb - Fatal编程技术网

将MariaDB与Django 1.10和Python 3.5一起使用

将MariaDB与Django 1.10和Python 3.5一起使用,python,django,ubuntu,mariadb,Python,Django,Ubuntu,Mariadb,我想将我的数据库从SQLite迁移到MariaDB。运行Ubuntu 14.04、Django 1.10和Python 3.5,但它默认使用的是Python2.x,而不是3.x。它们使用默认的mySQL连接器MySQLdb。这不适用于python 3.x,首选的替代方案是mysqlsclient: pip install mysqlclient 但这给了: Collecting mysqlclient Using cached mysqlclient-1.3.9.tar.gz Buildi

我想将我的数据库从SQLite迁移到MariaDB。运行Ubuntu 14.04、Django 1.10和Python 3.5,但它默认使用的是Python2.x,而不是3.x。它们使用默认的mySQL连接器MySQLdb。这不适用于python 3.x,首选的替代方案是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开发包,但它们正在解析为python3.6,我在我的virtualenv中使用了python3.4

我所要做的就是:

sudo apt-get install python3.4-dev

因为您使用的是python3,所以您需要
python3-dev
而不是
Python-dev
。我只是还没有时间尝试一下。
python3dev
已经安装好了。没问题,我没有其他建议。希望你能找到答案。