{"id":1064,"date":"2009-05-28T05:15:42","date_gmt":"2009-05-27T21:15:42","guid":{"rendered":"http:\/\/fanhaijun.com\/?p=1064"},"modified":"2009-05-28T05:15:42","modified_gmt":"2009-05-27T21:15:42","slug":"%e5%9c%a8windows%e4%b8%8a%e5%ae%89%e8%a3%85pythonmysql-%e7%9a%84%e5%b8%b8%e8%a7%81%e9%97%ae%e9%a2%98%e5%8f%8a%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fanhaijun.com\/?p=1064","title":{"rendered":"\u5728Windows\u4e0a\u5b89\u88c5Python+MySQL \u7684\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"<p>\u9a8c\u8bc1\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86MySQLdb\uff1a<\/p>\n<p>==========================================================<br \/>\nd:\\usr\\local\\Python25&gt;python<br \/>\nPython 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] onwin32<br \/>\nType &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br \/>\n&gt;&gt;&gt; import MySQLdb<br \/>\nTraceback (most recent call last):<br \/>\n\u00a0 File &#8220;&lt;stdin&gt;&#8221;, line 1, in &lt;module&gt;<br \/>\nImportError: No module named MySQLdb<br \/>\n==========================================================<br \/>\n\u5982\u679c\u6709\u7c7b\u4f3c\u4e8e\u4e0a\u9762\u7684&#8221;No module named MySQLdb&#8221;\uff0c\u8868\u660eMySQLdb\u5c1a\u672a\u5b89\u88c5\u6216\u5b89\u88c5\u7684\u4e0d\u6210\u529f\uff01<\/p>\n<p>MySQL \u7248\u672c\uff1a5.0.67<br \/>\n\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/dev.mysql.com\/downloads\/mysql\/5.0.html#downloads\">http:\/\/dev.mysql.com\/downloads\/mysql\/5.0.html#downloads<\/a><br \/>\n\u4e0b\u8f7dexe\u6587\u4ef6\u5e76\u5b89\u88c5<\/p>\n<p>==========================================================<\/p>\n<p>Python \u7248\u672c\uff1a2.5<br \/>\n\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/www.python.org\/download\/releases\/2.5.4\/\">http:\/\/www.python.org\/download\/releases\/2.5.4\/<\/a><br \/>\n\u4e0b\u8f7dmsi\u6587\u4ef6\u5e76\u5b89\u88c5<\/p>\n<p>MySQLdb\u7248\u672c\uff1a MySQLdb Windows binary for Python 2.5<br \/>\n\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/biohackers.net\/wikiattach\/Python2%282e%295\/attachments\/MySQL-python.exe-1.2.1_p2.win32-py2.5.exe\">http:\/\/biohackers.net\/wikiattach\/Python2(2e)5\/attachments\/MySQL-python.exe-1.2.1_p2.win32-py2.5.exe<\/a><br \/>\n\u53c2\u89c1\uff1a<a href=\"http:\/\/forums.mysql.com\/read.php?50,129618,140611#msg-140611\">http:\/\/forums.mysql.com\/read.php?50,129618,140611#msg-140611<\/a><\/p>\n<p>\u5e38\u89c1\u95ee\u9898\uff1a<br \/>\n1.\u65e0\u6cd5\u5b9a\u4f4d\u7a0b\u5e8f\u8f93\u5165\u70b9 mysql_server_init \u4e8e\u52a8\u6001\u94fe\u63a5\u5e93 LIBMYSQL.dll \u4e0a\u3002<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nD:\\usr\\local\\Python25&gt;python<br \/>\nPython 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32<br \/>\nType &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br \/>\n&gt;&gt;&gt; import MySQLdb<br \/>\nTraceback (most recent call last):<br \/>\n\u00a0 File &#8220;&lt;stdin&gt;&#8221;, line 1, in &lt;module&gt;<br \/>\n\u00a0 File &#8220;D:\\usr\\local\\Python25\\Lib\\site-packages\\MySQLdb\\__init__.py&#8221;, line 19, in &lt;module&gt;<br \/>\n\u00a0\u00a0\u00a0 import _mysql<br \/>\nImportError: DLL load failed: \u627e\u4e0d\u5230\u6307\u5b9a\u7684\u7a0b\u5e8f\u3002<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n\u89e3\u51b3\u65b9\u6cd5\uff1a\u628amysql\u5b89\u88c5\u76ee\u5f55\u7684bin\\libmySQL.dll\u6587\u4ef6\u590d\u5236\u5230python\u5b89\u88c5\u76ee\u5f55\u7684Lib\\site-packages\u4e0b<\/p>\n<p>==========================================================<\/p>\n<p>Python \u7248\u672c\uff1a2.6<br \/>\n\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/www.python.org\/download\/releases\/2.6.1\/\">http:\/\/www.python.org\/download\/releases\/2.6.1\/<\/a><br \/>\n\u4e0b\u8f7dmsi\u6587\u4ef6\u5e76\u5b89\u88c5<\/p>\n<p>MySQLdb\u7248\u672c\uff1a MySQL-python-1.2.2.win32-py2.6.exe<br \/>\n\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/home.netimperia.com\/files\/misc\/MySQL-python-1.2.2.win32-py2.6.exe\">http:\/\/home.netimperia.com\/files\/misc\/MySQL-python-1.2.2.win32-py2.6.exe<\/a><br \/>\n\u53c2\u89c1\uff1a<a href=\"http:\/\/sourceforge.net\/forum\/forum.php?thread_id=2316047&amp;forum_id=70460\">http:\/\/sourceforge.net\/forum\/forum.php?thread_id=2316047&amp;forum_id=70460<\/a><\/p>\n<p>\u5e38\u89c1\u95ee\u9898\uff1a<br \/>\n1.ImportError: DLL load failed: \u627e\u4e0d\u5230\u6307\u5b9a\u7684\u6a21\u5757\u3002<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nD:\\usr\\local\\Python26&gt;python<br \/>\nPython 2.6 (r26:66721, Oct\u00a0 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32<br \/>\nType &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br \/>\n&gt;&gt;&gt; import MySQLdb<br \/>\nTraceback (most recent call last):<br \/>\n\u00a0 File &#8220;&lt;stdin&gt;&#8221;, line 1, in &lt;module&gt;<br \/>\n\u00a0 File &#8220;D:\\usr\\local\\Python26\\Lib\\site-packages\\MySQLdb\\__init__.py&#8221;, line 19, in &lt;module&gt;<\/p>\n<p>\u00a0\u00a0\u00a0 import _mysql<br \/>\nImportError: DLL load failed: \u627e\u4e0d\u5230\u6307\u5b9a\u7684\u6a21\u5757\u3002<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n\u89e3\u51b3\u65b9\u6cd5\uff1a\u4e0b\u8f7dlibmmd.dll(\u9644\u4ef6)\u548clibguide40.dll(\u9644\u4ef6)\u4e24\u4e2adll\u6587\u4ef6\u5e76\u590d\u5236\u5230python\u5b89\u88c5\u76ee\u5f55\u7684Lib\\site-packages\u4e0b\u3002<br \/>\n\u53c2\u89c1\uff1a<a href=\"http:\/\/sourceforge.net\/forum\/message.php?msg_id=5613887\">http:\/\/sourceforge.net\/forum\/message.php?msg_id=5613887<\/a><\/p>\n<p>2.ImportError: DLL load failed: \u627e\u4e0d\u5230\u6307\u5b9a\u7684\u6a21\u5757\u3002<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nD:\\usr\\local\\Python26&gt;python<br \/>\nPython 2.6 (r26:66721, Oct\u00a0 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32<br \/>\nType &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br \/>\n&gt;&gt;&gt; import MySQLdb<br \/>\nD:\\usr\\local\\Python26\\lib\\site-packages\\MySQLdb\\__init__.py:34: DeprecationWarning: the sets module is deprecated<br \/>\n\u00a0 from sets import ImmutableSet<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n\u89e3\u51b3\u65b9\u6cd5\uff1a<br \/>\n<span class=\"Apple-style-span\" style=\"TEXT-ALIGN: left; WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: collapse; FONT: 12px\/14px 'Courier New'; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: #000000; WORD-SPACING: 0px; font-size-adjust: none; font-stretch: normal; -x-system-font: none\">1) file &#8220;__init__&#8221;, replace:\u00a0<br \/>\n\u00a0<br \/>\nfrom sets import ImmutableSet \u00a0<br \/>\nclass DBAPISet(ImmutableSet): \u00a0<br \/>\n\u00a0<br \/>\nwith \u00a0<br \/>\n\u00a0<br \/>\nclass DBAPISet(frozenset)\u00a0<br \/>\n\u00a0<br \/>\n2) file &#8220;converters.py&#8221;, remove:\u00a0<br \/>\n\u00a0<br \/>\nfrom sets import BaseSet, Set\u00a0<br \/>\n\u00a0<br \/>\n3) file &#8220;converters.py&#8221;, change &#8220;Set&#8221; by &#8220;set&#8221; (IMPORTANT: only two places):\u00a0<br \/>\n\u00a0<br \/>\nline 48: return set([ i for i in s.split(&#8216;,&#8217;) if i ])\u00a0<br \/>\nline 128: set: Set2Str,\u00a0<br \/>\n\u53c2\u89c1\uff1a<a href=\"http:\/\/sourceforge.net\/forum\/message.php?msg_id=5808948\">http:\/\/sourceforge.net\/forum\/message.php?msg_id=5808948<\/a><\/span><\/p>\n<p><a href=\"http:\/\/fanhaijun.com\/wp-content\/uploads\/2009\/05\/pythone79bb8e585b3.rar\">\u76f8\u5173\u9644\u4ef6<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9a8c\u8bc1\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86MySQLdb\uff1a ============&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[104],"tags":[],"class_list":["post-1064","post","type-post","status-publish","format-standard","hentry","category-technogy"],"_links":{"self":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/1064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1064"}],"version-history":[{"count":0,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/1064\/revisions"}],"wp:attachment":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}