[分享]在Windows下安装Python+MySQL 的常见有关问题及解决_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2266 | 回复: 0   主题: [分享]在Windows下安装Python+MySQL 的常见有关问题及解决        下一篇 
第五种族
注册用户
等级:列兵
经验:103
发帖:78
精华:0
注册:2011-11-3
状态:离线
发送短消息息给第五种族 加好友    发送短消息息给第五种族 发消息
发表于: IP:您无权察看 2014-12-4 9:24:46 | [全部帖] [楼主帖] 楼主

验证是否已经安装了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
==========================================================


如果有类似于上面的"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,




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论