pip-3.3 安装 MySQL-python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20049590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip-3.3 install MySQL-python
提问by Droid
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)
pip-3.3 -V pip 1.4.1 来自 /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..
如何在 Python3.3 中安装 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
采纳答案by Ron
回答by tanmay
In python3, install MySQL-python-1.2.5 by source, and before that, you need to modify source as mentioned below:
在python3中,通过source安装 MySQL-python-1.2.5 ,在此之前,你需要修改 source 如下:
- Replace
ConfigParserbyconfigparserin file MySQL-python-1.2.5/setup_posix.py file - Modify line 191,
except TypeError, m:toexcept TypeError as m:in file MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/cursors.py file - Modify line 250,
except TypeError, msg:toexcept TypeError as msg:in same cursors.py file - Modify line 36,
raise errorclass, errorvaluetoraise errorclass(errorvalue)in MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/connections.py file
- 替换
ConfigParser为configparserMySQL-python-1.2.5/setup_posix.py 文件中的文件 - 修改第 191 行,
except TypeError, m:到except TypeError as m:文件 MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/cursors.py 文件中 - 将第 250 行修改
except TypeError, msg:为except TypeError as msg:在同一个 cursors.py 文件中 - 修改第 36 行,
raise errorclass, errorvalue到raise errorclass(errorvalue)MySQL-python-1.2.5/build/lib.linux-x86_64-3.4/MySQLdb/connections.py 文件中
To understand more, see Python3 porting guide.
要了解更多信息,请参阅Python3 移植指南。
回答by Ruslan
pip install --allow-external mysql-connector-python
Edit settings.py
编辑设置.py
'ENGINE': 'mysql.connector.django',

