• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

在Windows上安装Python+MySQL 的常见有关问题及解决办法

mysql 搞代码 7年前 (2018-06-06) 152次浏览 已收录 0个评论

在Windows上安装Python+mysql 的常见问题及解决方法

验证是否已经安装了MySQLdb:

==========================================================

d: /usr/local/Python25> python Python 2. 5. 4 ( r254: 67916 ,  Dec 23  2008 ,  15 : 10 : 54 )  [ MSC v. 1310 32  bit ( Intel) ]  onwin32 Type "help" ,  "copyright" ,  "credits"  or "license"  for  more information.  >>>  import MySQLdb Traceback ( most recent call last) :    File  "<stdin>" ,  line 1 ,  in < module>  ImportError:  No module named MySQLdb

欢迎大家阅读《在Windows上安装Python+MySQL 的常见有关问题及解决办法》,跪求各位点评,by 搞代码

==========================================================
如果有类似于上面的”No module named MySQLdb”,表明MySQLdb尚未安装或安装的不成功!

MySQL 版本:5.0.67
下载地址:http://dev.mysql.com/downloads/mysql/5.0.html#downloads
下载exe文件并安装

==========================================================

Python 版本:2.5
下载地址:http://www.python.org/download/releases/2.5.4/
下载msi文件并安装

MySQLdb版本: MySQLdb Windows binary for Python 2.5
下载地址:http://biohackers.net/wikiattach/Python2(2e)5/attachments/MySQL-python.exe-1.2.1_p2.win32-py2.5.exe
参见:http://forums.mysql.com/read.php?50,129618,140611#msg-140611

常见问题:
1.无法定位程序输入点 mysql_server_init 于动态链接库 LIBMYSQL.dll 上。
—————————————————————————————————-

D: /usr/local/Python25> python Python 2. 5. 4 ( r254: 67916 ,  Dec 23  2008 ,  15 : 10 : 54 )  [ MSC v. 1310 32  bit ( Intel) ]  on win32 Type "help" ,  "copyright" ,  "credits"  or "license"  for  more information.  >>>  import MySQLdb Traceback ( most recent call last) :    File  "<stdin>" ,  line 1 ,  in < module>    File  "D:/usr/local/Python25/Lib/site-packages/MySQLdb/__init__.py" ,  line 19 ,  in < module>      import _mysql ImportError:  DLL load failed:  找不到指定的程序。

—————————————————————————————————-
解决方法:把mysql安装目录的bin/libmySQL.dll文件复制到python安装目录的Lib/site-packages下

==========================================================

Python 版本:2.6
下载地址:http://www.python.org/download/releases/2.6.1/
下载msi文件并安装

MySQLdb版本: MySQL-python-1.2.2.win32-py2.6.exe
下载地址:http://home.netimperia.com/files/misc/MySQL-python-1.2.2.win32-py2.6.exe
参见:http://sourceforge.net/forum/forum.php?thread_id=2316047&forum_id=70460

常见问题:
1.ImportError: DLL load failed: 找不到指定的模块。
—————————————————————————————————-

D: /usr/local/Python26> python Python 2.6  ( r26: 66721 ,  Oct  2  2008 ,  11 : 35 : 03 )  [ MSC v. 1500 32  bit ( Intel) ]  on win32 Type "help" ,  "copyright" ,  "credits"  or "license"  for  more information.  >>>  import MySQLdb Traceback ( most recent call last) :    File  "<stdin>" ,  line 1 ,  in < module>    File  "D:/usr/local/Python26/Lib/site-packages/MySQLdb/__init__.py" ,  line 19 ,  in < module>        import _mysql ImportError:  DLL load failed:  找不到指定的模块。

—————————————————————————————————-
解决方法:下载libmmd.dll(附件)和libguide40.dll(附件)两个dll文件并复制到python安装目录的Lib/site-packages下。
参见:http://sourceforge.net/forum/message.php?msg_id=5613887

2.ImportError: DLL load failed: 找不到指定的模块。
—————————————————————————————————-

D: /usr/local/Python26> python Python 2.6  ( r26: 66721 ,  Oct  2  2008 ,  11 : 35 : 03 )  [ MSC v. 1500 32  bit ( Intel) ]  on win32 Type "help" ,  "copyright" ,  "credits"  or "license"  for  more information.  >>>  import MySQLdb D: /usr/local/Python26/lib/site- packages/MySQLdb/__init__. py: 34 :  DeprecationWarning:  the sets module is deprecated   from sets import ImmutableSet

—————————————————————————————————-
解决方法:
1) file “__init__”, replace:

from sets import ImmutableSet   class  DBAPISet( ImmutableSet) :      with     class  DBAPISet( frozenset) 

2) file “converters.py”, remove:

from sets import BaseSet,  Set

3) file “converters.py”,

change "Set"  by "set"  ( IMPORTANT:  only two places) :     line 48 :  return  set( [  i for  i in s. split ( ',' )  if  i ] )   line 128 :  set:  Set2Str, 

参见:http://sourceforge.net/forum/message.php?msg_id=5808948


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:在Windows上安装Python+MySQL 的常见有关问题及解决办法

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址