I am getting an error
pip version
pip-3.3 -V pip 1.4.1 from /usr/local/lib/python3.3/site-packages/pip-1.4.1-py3.3.egg (python 3.3)
how to install MySQLdb in Python3.3 helpp..
root@thinkpad:~# pip-3.3 install MySQL-python
Downloading/unpacking MySQL-python
Downloading MySQL-python-1.2.4.zip (113kB): 113kB downloaded
Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip_build_root/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip_build_root/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/MySQL-python
Storing complete log in /root/.pip/pip.log
In python3 ConfigParser
was renamed to configparser
. It seems MySQL-python
does not support python3. Try:
$ pip install PyMySQL
PyMySQL is a different module, but it supports python3.
In python3, install MySQL-python-1.2.5 by source , and before that, you need to modify source as mentioned below:
ConfigParser
by configparser
in file MySQL-python-1.2.5/setup_posix.py file except TypeError, m:
to except TypeError as m:
in file MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/cursors.py file except TypeError, msg:
to except TypeError as msg:
in same cursors.py file raise errorclass, errorvalue
to raise errorclass(errorvalue)
in MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/connections.py file To understand more, see Python3 porting guide .
pip install --allow-external mysql-connector-python
编辑settings.py
'ENGINE': 'mysql.connector.django',
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.