PC: MacOS X 10.9.4 Python3.4.1 Django1.6.6
Previous article I thought that the project was created successfully, but I noticed that the database settings of ʻEclipse` below were not reflected. ..
I synced with the database ($ python3 manage.py syncdb
), but it is not reflected in the target MySQL
database. When I check the description of the DB setting in setting.py
, it is the setting of sqlite3
. So I commented it out and wrote the settings for mySQL
directly.
setting.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django_db',
'USER':'db_user',
'PASSWORD':'xxxxxxx',
'HOST':'localhost',
'PORT':'3306',
}
}
#DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
#}
However, when I synced ($ python3 manage.py syncdb
) again, the following error came to occur.
ImportError: No module named 'MySQLdb'
Apparently, I can't find the MySQL
module. So I tried to install the MySQL
module.
$ pip3 install mysql-python
However, this time the following error.
ImportError: No module named 'ConfigParser'
This time, I tried to install it below.
$ pip3 install mysql-connector-python --allow-external mysql-connector-python
This time, the installation itself seems to have worked. However, the error still continues.
ImportError: No module named 'MySQLdb'
I didn't give up, and the latest MySQL-for-Python-3
was on Github, so I tried installing it.
pip3 install --user https://github.com/davispuh/MySQL-for-Python-3/archive/1.0.tar.gz
The installation itself seems to have worked. But another error follows.
Library not loaded: libmysqlclient.18.dylib
So I made a symbolic link for libmysqlclient.18.dylib
in / usr / lib
, which would be in the MySQL
library.
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
After that, I read the Django Official Manual and found the following description.
Python 3 At the time of writing, the latest release of MySQLdb (1.2.4) doesn’t support Python 3. In order to use MySQL under Python 3, you’ll have to install an unofficial fork, such as MySQL-for-Python-3. This port is still in alpha. In particular, it doesn’t support binary data, making it impossible to use django.db.models.BinaryField.
Put simply,
Python3 At the time of writing, the latest release of MySQLdb (1.2.4) does not support Python 3. If you use MySQL, you should install an unofficial fork version like MySQL-for-Python-3. This port is still an alpha version, especially because it doesn't support binary data, so django.db.modules.BinaryField isn't available either.
Hmmm ~.
Apparently, as far as I can check on the Web and the manual, it seems that MySQLdb
does not support Python3
at this time (end of August 2014).
So how should we give up?
Since I'm a beginner of Python
, I can't get a sense of the release interval (how long I should wait for it to be supported).
By the way, I was addicted to Ruby on Rails
a year or two ago around the MySQL
connector.
After all, I feel that it is not a problem for Python
beginners to poke their necks. I am disappointed, so please give me some advice and suggestions.
Recommended Posts