I
I
IgaIst2013-03-21 23:24:53
MySQL
IgaIst, 2013-03-21 23:24:53

Django + MySQL + Windows = Error?

Already spent a lot of time trying to pair Django with MySQL on Windows.
Mistake:

Unhandled exception in thread started by <bound method Command.inner_run of <dja
ngo.contrib.staticfiles.management.commands.runserver.Command object at 0x000000
00031B22B0>>
Traceback (most recent call last):
  File "c:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 92, in inner_run
    self.validate(display_num_errors=True)
  File "c:\Python27\lib\site-packages\django\core\management\base.py", line 280,
 in validate
    num_errors = get_validation_errors(s, app)
  File "c:\Python27\lib\site-packages\django\core\management\validation.py", lin
e 28, in get_validation_errors
    from django.db import models, connection
  File "c:\Python27\lib\site-packages\django\db\__init__.py", line 40, in <modul
e>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "c:\Python27\lib\site-packages\django\db\__init__.py", line 34, in __geta
ttr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 93, in __getitem
__
    backend = load_backend(db['ENGINE'])
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 27, in load_back
end
    return import_module('.base', backend_name)
  File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
    __import__(name)
  File "c:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 17
, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xed in position 20: ordinal
 not in range(128)

Config:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME' : 'pytest',      
        'USER': 'root',
        'PASSWORD': '',
        'HOST': 'localhost',                 
        'PORT': '3306',                      
    }
}

Please tell me how to solve this problem

Answer the question

In order to leave comments, you need to log in

6 answer(s)
C
Could, 2013-03-22
@IgaIst

I had the same problem, the reason was the uninstalled mysqldb library on windows. This solved the problem.

@
@ntkt, 2013-03-21
_

Check that there is no Cyrillic alphabet anywhere, anywhere:
-% PATH% and other environment variables
- computer name
- CLSID from Python associations
- perhaps in the settings of the muscle and its firewood
In general, judging by what they write on the Internet, it's cheaper to raise a virtual linux than to debug it :(

I
igrishaev, 2013-03-22
@igrishaev

In our office, Django and Muskul are spinning on Windows, the flight is normal.
Error in this statement:
>>> import MySQLdb as Database
Open interactive Python and run this code.
Question - do you have classic Python or ActivePython? The latter stores packages by default not in site-packages, but somewhere in the asshole of Windows, when starting Jungi through Apache / IIS, this path may not be picked up.

P
Pavel Zagrebelin, 2013-03-22
@Zagrebelion

open c:\Python27\lib\site-packages\django\db\backends\mysql\base.py, in line 16 paste

import pdb
pdb.set_trace()

and in the console, when pdb drops out, write print e. What will happen?

I
igrishaev, 2013-03-22
@igrishaev

Check the python paths for Cyrillic characters:

python manage.py shell
>>> import sys
>>> print sys.path

B
blazer-05, 2015-12-31
@blazer-05

Hello.
Help me with a problem. Under windows 7 32bit installed python 2.7.8, django 1.7.1, mysql. Everything seems to work, the site opens and pulls data from the database, but in the shell console when I execute such a command

from django.db import connection
cursor = connection.cursor()

an error occurs
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: this is MySQLdb version (1, 2, 3, 'final', 0), but _mysql is version (1, 3, 4, 'final', 1)

The module for my MySQL-python-1.2.5.win32-py2.7 operating system is installed, I also installed mysqlclient 1.3.4, pymysql, but nothing happens, the error is true!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question