mysql python安装错误,Windows上具有MySQL的Python:安装错误

I tried to run the following command, in the folder of my Django project:

$ python manage.py dbshell

It shows me this error:

$python manage.py dbshell

Traceback (most recent call last):

File "manage.py", line 11, in

execute_manager(settings)

File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line

362, in execute_manager

utility.execute()

File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line

303, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "C:\Python25\lib\site-packages\django\core\management\base.py", line 195,

in run_from_argv

self.execute(*args, **options.__dict__)

File "C:\Python25\lib\site-packages\django\core\management\base.py", line 222,

in execute

output = self.handle(*args, **options)

File "C:\Python25\lib\site-packages\django\core\management\base.py", line 351,

in handle

return self.handle_noargs(**options)

File "C:\Python25\lib\site-packages\django\core\management\commands\dbshell.py

", line 9, in handle_noargs

from django.db import connection

File "C:\Python25\lib\site-packages\django\db\__init__.py", line 41, in

e>

backend = load_backend(settings.DATABASE_ENGINE)

File "C:\Python25\lib\site-packages\django\db\__init__.py", line 17, in load_b

ackend

return import_module('.base', 'django.db.backends.%s' % backend_name)

File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line 35, in im

port_module

__import__(name)

File "C:\Python25\lib\site-packages\django\db\backends\mysql\base.py", line 13

, in

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo

dule named MySQLdb

First question is, why does Python not simply include this MySQLdb module?

OK, just fine, try to search to solve this message.

I have looked around stackoverflow.com for installing this module but did not have a good result.

Comes to the installation of this module on my Windows Vista system.

After the extraction of the package, I run the cmd prompt to continue with the installation:

$ python setup.py install

Again it showed me one other message:

D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install

Traceback (most recent call last):

File "setup.py", line 5, in

from setuptools import setup, Extension

ImportError: No module named setuptools

Playing around with this error message, I know that there is the ez_setup.py within the package:

$python ez_setup.py

It seems that everything is OK:

D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python ez_setup.py

Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py

2.5.egg

Processing setuptools-0.6c9-py2.5.egg

Copying setuptools-0.6c9-py2.5.egg to c:\python25\lib\site-packages

Adding setuptools 0.6c9 to easy-install.pth file

Installing easy_install-script.py script to C:\Python25\Scripts

Installing easy_install.exe script to C:\Python25\Scripts

Installing easy_install-2.5-script.py script to C:\Python25\Scripts

Installing easy_install-2.5.exe script to C:\Python25\Scripts

Installed c:\python25\lib\site-packages\setuptools-0.6c9-py2.5.egg

Processing dependencies for setuptools==0.6c9

Finished processing dependencies for setuptools==0.6c9

Now comes back to the setup.py to install again:

$python setup.py install

It again gave me one other error message:

D:\SOFTWARE\PROGRAMMING\MySQL-python-1.2.3c1>python setup.py install

running install

running bdist_egg

....

copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.5\MySQLdb\constants

running build_ext

error: Python was built with Visual Studio 2003;

extensions must be built with a compiler than can generate compatible binaries.

Visual Studio 2003 was not found on this system. If you have Cygwin installed,

you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

How can I fix this problem?

解决方案

That is the download area of MySQLdb project, it has nothing to do with django, so your question is incorrect - django does not make switching database backends hard, you just change one line. And of course, your python installation should support that database first, so by downloading binary package for Windows from the link I gave above (chose correct version to match your version of python) you can avoid all the hassle of compiling the source release.

Most probably you need either MySQL-python-1.2.2.win32-py2.5.exe or MySQL-python-1.2.2.win32-py2.4.exe

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值