[英]pip-3.3 install MySQL-python
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) 来自/usr/local/lib/python3.3/site-packages/pip-1.4.1-py3.3.egg(python 3.3)的pip-3.3 -V pip 1.4.1
how to install MySQLdb in Python3.3 helpp.. 如何在Python3.3 helpp中安装MySQLdb ..
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, install MySQL-python-1.2.5 by source , and before that, you need to modify source as mentioned below: 在python3中,按源安装MySQL-python-1.2.5,在此之前,您需要修改源代码,如下所述:
ConfigParser
by configparser
in file MySQL-python-1.2.5/setup_posix.py file 在文件MySQL-python-1.2.5 / configparser
文件中用configparser
替换ConfigParser
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 修改第191行, except TypeError, m:
except TypeError as m:
在文件MySQL-python-1.2.5 / build / lib.linux-x86_64-3.4 / MySQLdb / cursors.py文件中 except TypeError, msg:
to except TypeError as msg:
in same cursors.py file 修改第250行, except TypeError, msg:
to, except TypeError as msg:
在同一个cursors.py文件中 raise errorclass, errorvalue
to raise errorclass(errorvalue)
in MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/connections.py file 在MySQL-python-1.2.5 / build / lib.linux-x86_64-3.4 / MySQLdb / connections.py文件中修改第36行, raise errorclass, errorvalue
以raise errorclass(errorvalue)
To understand more, see Python3 porting guide . 要了解更多信息,请参阅Python3移植指南 。
pip install --allow-external mysql-connector-python
编辑settings.py
'ENGINE': 'mysql.connector.django',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.